[Prev][Next][Index][Thread]

Stange problem on sockets



Hi

I have a strange problem that I don't understand - I hope you can help
me.

After I have the sockets non-blocking in the Library, I have found that
when I connect to a port where I know that I will get `connection
refused', e.g. port 81 or something - this is _not_ what I get. Instead
I get errno 22 - `invalid argument'.

I have now stripped down a test version which is very simple. I do the
following:

	- initialize the sockaddr structure 
	- create a socket with the host
	- make it non-blocking using ioctl	<------
	- do a connect
	- get `would block' back
	- make a select waiting for write on socket
	- on return from select I do a new connect
	- I get errno 22: invalid argument

I have a loop around the connect so that infact I am pending on the
resonse - nothing is touched. If I do exactly the same using blocking
sockets there is no problem - I get the `connection refused' as I would
expect. As soon as I turn the non-blocking sockets on - I get the
`invalid argument'. I have just checked - Mosaic gets the same - but it
doesn't say it to the user as far as I can see.

I have tested it on osf1 and SunOS. Solaris returns `broken pipe' so
this is not much help.

Is it something I have to live with or is there a work-around???

-- cheers --

Henrik