Hello Net,
I've got one strange problem with a tcp-connection on
solaris 2.4 workstations (sparc 10).
I open the connection on the one side (eliasd) with the following
sequence:
elias_socket=socket(AF_INET,SOCK_STREAM,0);
setsockopt(basis_socket,SOL_SOCKET,SO_REUSEADDR,(char*)&one,sizeof(one));
setsockopt(elias_socket,SOL_SOCKET,SO_LINGER,(char*)&one,sizeof(one));
memset(&demon,'\0',sizeof(demon));
demon.sin_port = htonl(ELIAS_PORT);
bind(basis_socket,(struct sockaddr*)&demon,sizeof(demon));
listen(basis_socket,5);
(I removed the error-checking from the code) Then i accept on the socket:
s=accept(elias_socket,0,0);
The other side (client) does this:
demon = socket(AF_INET,SOCK_STREAM,0);
memset(&demon_addr,'\0',sizeof(struct sockaddr_in));
hp = gethostbyname(host);
memcpy((char*)&demon_addr.sin_addr,hp->h_addr_list[0],hp->h_length);
demon_addr.sin_family = hp->h_addrtype;
demon_addr.sin_port = htonl(ELIAS_PORT);
result=connect(demon,&demon_addr,sizeof(demon_addr));
After the connect, the accept returns and i start sending bytes from
demon to elias_socket. It all seems to work, except when eliasd and client
are running on the same solaris2.4 machine: the first write from client
succeds but from the second write 5 bytes are lacking. This does not happen
when eliasd and the client are on different machines (be it sunos4 or
solaris). Any idea anyone??
Second question: How do I put a timeout on my accept(), so that after a
certain amount of time accept returns and i can do some housekeping?
Do I have to select on elias_socket?
it would be nice to hear from you..
Thomas Fettig