Re: Problems with sockets
- From: Sri Harsha Dandibhotla <harsha.dsh@xxxxxxxxx>
- Date: Thu, 27 Aug 2009 22:58:59 -0700 (PDT)
On Aug 27, 10:29 pm, Hakan <H...@xxxxxxxxxxxx> wrote:
Ben Bacarisse wrote:
Nobody <nob...@xxxxxxxxxxx> writes:
On Thu, 27 Aug 2009 08:41:11 +0200, Hakan wrote:
The server code quoted below keeps giving me errors. The bind call
returns -1 every time I try it.
And what does it set errno to?This question has been re-posted on another group but it turns out the
problem is, after all, a C one:
There are missing ()s round the assignment.if (sockint=socket(hp->h_addrtype,SOCK_STREAM,ptrp->p_proto)>=0)
C advice to the OP: turn on more warnings from you compiler!
Still get the same problem from this after adding the parenthesis.
Perror types out "Socket operation on non-socket". Thanks.
I think you didn't get what Ben Bacarisse meant?
change to if ((sockint=socket(hp->h_addrtype,SOCK_STREAM,ptrp-if (sockint=socket(hp->h_addrtype,SOCK_STREAM,ptrp->p_proto)>=0)
p_proto))>=0)assigning to sockint in your statement is not the socket descriptor
From the error message, this must be the problem. What you are
returned by the call but rather the truth value on comparison with 0.
Hence the error message saying socket operation on non-socket.
.
- References:
- Problems with sockets
- From: Hakan
- Re: Problems with sockets
- From: Nobody
- Re: Problems with sockets
- From: Ben Bacarisse
- Re: Problems with sockets
- From: Hakan
- Problems with sockets
- Prev by Date: Re: K&R 1-24
- Next by Date: why is this variable read-only
- Previous by thread: Re: Problems with sockets
- Next by thread: Problems with sockets
- Index(es):
Relevant Pages
|