LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   socket programming (https://www.linuxquestions.org/questions/programming-9/socket-programming-339817/)

iiit 07-04-2005 05:20 AM

socket programming
 
hi

I am writing a server, and because it is going to be used in distributed enviornment, it should be robus. SO i am trying to
incorporate all error handling in it. I am encountering following problems.



client:

loop{

#1 read from server;

#2 read from terminal(take input)

#3 write to the server;

}


server:

loop{

#4 write to the client;

#5 read from the client;


}



scenario is like this:
a) client is blocked in line #2. server is blocked in line #5.and suddenly client crashes(ctrl+c). As expected server reads
EOF from the socket, but continue to operate (plz dont ask why, i want to have SIGPIPE in write only). It continues to write
without error first time(because upto this time only FIN has arrived to this socket), and even continues to read from the client(line #5,it is returning 0,its ok). no problem upto this point.
now again when server wants to write to the socket(line#4), it recieves SIGPIPE and process exits.(no problem, because
according to stevens- an attempt to write on the socket, which has recieved RST , will cause SIGPIPE).

but real problem start now- Above scenario is when i am running server and client both on local system. If i try to run server and client in 2 distantly separated systems, server continues to write 8-10 times on the socket, even after getting FIN on the socket.

i think, RST packet that is sent by the closed client( when attempted to write into it), is taking time to reach to the servera
nd because server didn't recieve RST, it continues to write to the socket, irrespective of the fact that it has closed.


can any one plz tell something about the solution.

thanks

chinmaya

david_ross 07-05-2005 02:31 PM

Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.

exvor 07-05-2005 04:02 PM

what programming language were you thinking of useing. Sorry i dont reconize the code you have here.


All times are GMT -5. The time now is 10:45 AM.