The Joel on Software Discussion Group (CLOSED)

A place to discuss Joel on Software. Now closed.

This community works best when people use their real names. Please register for a free account.

Other Groups:
Joel on Software
Business of Software
Design of Software (CLOSED)
.NET Questions (CLOSED)
Fog Creek Copilot

The Old Forum

Your hosts:
Albert D. Kallal
Li-Fan Chen
Stephen Jones

Qucik TCP/IP question ?

I open up a socket and connect to another one.
There is a network problem and I get an exception while writing to the socket.
The exeption handling code waits for 10 seconds and jumps back to the writing code.
While I am waiting the network is back.

Will the write call fail ???
Saturday, February 18, 2006
You can easily try this yourself by unplugging your cat5 cable or disabling your wireless connection.
Jonathan Ellis
Saturday, February 18, 2006
It depends on the type of socket you created.  You have raw, UDP, or TCP sockets.

In the case of RAW and UDP, you are, by definition, not guaranteed delivery.  With TCP, you are.

The exception tells me you have a bug in code.  If you drop a packet on the wire and it does not reach its destination, your code should not be generating an exception but rather an error return code that you should be checking.

I've done an enormous amount of socket communication work under Unix and Windows... Give more details or show some code and I may be of more help.
Eric (another ISV guy with his company)
Saturday, February 18, 2006
"If you drop a packet on the wire and it does not reach its destination, your code should not be generating an exception"

That really depends on the API you're using.

In fact, I would venture to guess that your statement is false for most that are higher-level than C.  Java, python, and .NET all use exceptions here, for instance.
Jonathan Ellis
Saturday, February 18, 2006
What can you learn from the exception?

A blanket "there was a problem" isn't much use. Find out whether there was a buffer overrun or a timeout or a strange response from the remote and work from there.
Saturday, February 18, 2006

I agree -- higher level languages probably do generate an exception.

In my line of work, I've done socket calls with C/C++ libraries that simply set an error code and return a failure on SocketSend(...).  This is true of Winsock and Unix. 

Some libraries wrap the socket libraries so hence my reason for asking for a code sample.

Thanks for the clarification!
Eric (another ISV guy with his company)
Monday, February 20, 2006

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz