Sponsored Content
Full Discussion: rlogin/rsh incoming port
Top Forums Programming rlogin/rsh incoming port Post 54502 by andryk on Tuesday 17th of August 2004 04:13:10 AM
Old 08-17-2004
rlogin/rsh incoming port

Hi all,

In need to know why my sample code below that connect to a rlogind (513) fails, but original unix rlogin does not ? (.rhosts is verified to be correct)

I heard rlogin/rsh bind to a reserved port before connecting to the rlogin server. what are they ???

Code:
   s = socket(AF_INET, SOCK_STREAM, 0);
   sck.sin_family      = AF_INET;
   sck.sin_port        = htons(513);
   sck.sin_addr.s_addr = inet_addr("192.168.15.40");

   if (connect(s, (struct sockaddr *)&sck,sizeof(sck)) <0) {
      printf("connect() error\n"); return;
   }
   printf("Connected %d\n",s);
   write(s,"",1);
   write(s,"root",5);
   write(s,"root",5);
   write(s,"linux/38400",12);

   read(s,buf,sizeof(buf));
   printf("%s\n",buf);

Any help would be appreciated Smilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

rsh & rlogin

I'm trying to execute the next command: " rsh CompName date " which means i want to get the date from a machine which i have its CompName. but i get the answer : "Connection refused" what do i need to do ? how can i sign myself as user or guest in the other machine ? thanks in... (2 Replies)
Discussion started by: Inbal
2 Replies

2. Shell Programming and Scripting

Listening on port for incoming data?

I am not what I would call an experienced programmer. I know some ksh etc.. I need to be able to listening on a port for incoming data on a ultra 10 using solaris 9. Basically all that I need to do at the moment is to log the incoming data on a specific port number. Any ideas on how I... (6 Replies)
Discussion started by: frustrated1
6 Replies

3. Shell Programming and Scripting

ftp, rlogin , rcp, rsh are not wroking

Hi Friends I am facing one problem, I am not able to use ftp, rlogin , rcp, rsh in a particular server. when I am trying to ftp certain file from that server it is giving Connection closed by remote host. Now from other unix box I am not able to rlogin that particular server. as .rhosts... (3 Replies)
Discussion started by: itsjoy2u
3 Replies

4. IP Networking

handling incoming messages

I have a few clients connecting to the server(which is using select()) and theyre trying to send messages to each other. How do I wait for input on stdin and at the same time I wait for data to being sent from the server? Should I use select() in my client too? How exactly though? (1 Reply)
Discussion started by: charlitos
1 Replies

5. UNIX for Dummies Questions & Answers

RSH/rlogin problem

Hello, When I try and RSH/RLOGIN onto a box with user root, I get the prompt but the username/password combination NEVER work. I have the password up properly on the host machine. Does rsh/rlogin not make use of ./etc/passwd and /etc/shadow? (1 Reply)
Discussion started by: mojoman
1 Replies

6. Linux

incoming mails not coming

I am using Linux box. i am able to send mails through sendmail to local and other domains. i am not receving any incoming mails. dovecot service is running. (4 Replies)
Discussion started by: harishindn
4 Replies

7. UNIX for Advanced & Expert Users

which port for rsh

Hi, on AIX 6.1 , which port should be open for rsh commande ? When I issu the following : rsh myremoteserver -l oracle ls it hangs until I issue ctrl+c. What should I verify ? Thank you. (0 Replies)
Discussion started by: big123456
0 Replies

8. Shell Programming and Scripting

Rlogin / RSH / SSH

Hello, I am looking for a connection method in which i can connect to a remote server but I want to have only one chance to connect to the remote server (not to be asked for iuser name and password again). If I have provided a wrong password then I want the connection to broke and be routed... (1 Reply)
Discussion started by: LiorAmitai
1 Replies

9. AIX

Deny rsh,tn,or rlogin

Is there a way to deny access to a specific remote login option. example: usera--deny telnet access but keep rsh and rlogin userb--keeps telnet, rsh, and rlogin I'm basically trying to contol the access per services instead of changing the LOGIN REMOTELY(rsh,tn,rlogin) option to yes or no. (12 Replies)
Discussion started by: leemalloy
12 Replies

10. Solaris

How to find port number wwn of particular port on dual port HBA,?

please find the below o/p for your reference bash-3.00# fcinfo hba-port HBA Port WWN: 21000024ff295a34 OS Device Name: /dev/cfg/c2 Manufacturer: QLogic Corp. Model: 375-3356-02 Firmware Version: 05.03.02 FCode/BIOS Version: BIOS: 2.02; fcode: 2.01;... (3 Replies)
Discussion started by: sb200
3 Replies
sendfile(3EXT)						    Extended Library Functions						    sendfile(3EXT)

NAME
sendfile - send files over sockets or copy files to files SYNOPSIS
cc [ flag... ] file... -lsendfile [ library... ] #include <sys/sendfile.h> ssize_t sendfile(int out_fd, int in_fd, off_t *off, size_t len); DESCRIPTION
The sendfile() function copies data from in_fd to out_fd starting at offset off and of length len bytes. The in_fd argument should be a file descriptor to a regular file opened for reading. See open(2). The out_fd argument should be a file descriptor to a regular file opened for writing or to a connected AF_INET or AF_INET6 socket of SOCK_STREAM type. See socket(3SOCKET). The off argument is a pointer to a vari- able holding the input file pointer position from which the data will be read. After sendfile() has completed, the variable will be set to the offset of the byte following the last byte that was read. The sendfile() function does not modify the current file pointer of in_fd, but does modify the file pointer for out_fd if it is a regular file. The sendfile() function can also be used to send buffers by pointing in_fd to SFV_FD_SELF. RETURN VALUES
Upon successful completion, sendfile() returns the total number of bytes written to out_fd and also updates the offset to point to the byte that follows the last byte read. Otherwise, it returns -1, and errno is set to indicate the error. ERRORS
The sendfile() function will fail if: EAFNOSUPPORT The implementation does not support the specified address family for socket. EAGAIN Mandatory file or record locking is set on either the file descriptor or output file descriptor if it points at regular files. O_NDELAY or O_NONBLOCK is set, and there is a blocking record lock. An attempt has been made to write to a stream that cannot accept data with the O_NDELAY or the O_NONBLOCK flag set. EBADF The out_fd or in_fd argument is either not a valid file descriptor, out_fd is not opened for writing. or in_fd is not opened for reading. EINVAL The offset cannot be represented by the off_t structure, or the length is negative when cast to ssize_t. EIO An I/O error occurred while accessing the file system. ENOTCONN The socket is not connected. EOPNOTSUPP The socket type is not supported. EPIPE The out_fd argument is no longer connected to the peer endpoint. EINTR A signal was caught during the write operation and no data was transferred. USAGE
The sendfile() function has a transitional interface for 64-bit file offsets. See lf64(5). EXAMPLES
Example 1 Sending a Buffer Over a Socket The following example demonstrates how to send the buffer buf over a socket. At the end, it prints the number of bytes transferred over the socket from the buffer. It assumes that addr will be filled up appropriately, depending upon where to send the buffer. int tfd; off_t baddr; struct sockaddr_in sin; char buf[64 * 1024]; in_addr_t addr; size_t len; tfd = socket(AF_INET, SOCK_STREAM, 0); if (tfd == -1) { perror("socket"); exit(1); } sin.sin_family = AF_INET; sin.sin_addr.s_addr = addr; /* Fill in the appropriate address. */ sin.sin_port = htons(2345); if (connect(tfd, (struct sockaddr *)&sin, sizeof(sin))<0) { perror("connect"); exit(1); } baddr = (off_t)buf; len = sizeof(buf); while (len > 0) { ssize_t res; res = sendfile(tfd, SFV_FD_SELF, &baddr, len); if (res == -1) if (errno != EINTR) { perror("sendfile"); exit(1); } else continue; len -= res; } Example 2 Transferring Files to Sockets The following program demonstrates a transfer of files to sockets: int ffd, tfd; off_t off; struct sockaddr_in sin; in_addr_t addr; int len; struct stat stat_buf; ssize_t len; ffd = open("file", O_RDONLY); if (ffd == -1) { perror("open"); exit(1); } tfd = socket(AF_INET, SOCK_STREAM, 0); if (tfd == -1) { perror("socket"); exit(1); } sin.sin_family = AF_INET; sin.sin_addr = addr; /* Fill in the appropriate address. */ sin.sin_port = htons(2345); if (connect(tfd, (struct sockaddr *) &sin, sizeof(sin)) <0) { perror("connect"); exit(1); } if (fstat(ffd, &stat_buf) == -1) { perror("fstat"); exit(1); } len = stat_buf.st_size; while (len > 0) { ssize_t res; res = sendfile(tfd, ffd, &off, len); if (res == -1) if (errno != EINTR) { perror("sendfile"); exit(1); } else continue; len -= res; } ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
open(2), libsendfile(3LIB), sendfilev(3EXT), socket(3SOCKET), attributes(5), lf64(5) SunOS 5.11 31 May 2006 sendfile(3EXT)
All times are GMT -4. The time now is 09:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy