Re: Problems with sockets



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:
if (sockint=socket(hp->h_addrtype,SOCK_STREAM,ptrp->p_proto)>=0)
There are missing ()s round the assignment.
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?
if (sockint=socket(hp->h_addrtype,SOCK_STREAM,ptrp->p_proto)>=0)
change to if ((sockint=socket(hp->h_addrtype,SOCK_STREAM,ptrp-
p_proto))>=0)
From the error message, this must be the problem. What you are
assigning to sockint in your statement is not the socket descriptor
returned by the call but rather the truth value on comparison with 0.

Hence the error message saying socket operation on non-socket.
.



Relevant Pages

  • ftp daemon fails
    ... hi - all of a sudden i can't start the ftpd daemon. ... Socket operation on non-socket ... View this message in context: http://www.nabble.com/ftp-daemon-fails-tf4423871.html#a12619050 ...
    (freebsd-questions)
  • Re: ftp daemon fails
    ... Hash: SHA1 ... hi - all of a sudden i can't start the ftpd daemon. ... Socket operation on non-socket ...
    (freebsd-net)
  • Re: SOCK_RAW not supported
    ... succesfully but 'bind' still has same error "Socket operation on ... non-socket". ... With best regards, Roman Mashak. ...
    (comp.unix.programmer)
  • Re: ftp daemon fails
    ... Socket operation on non-socket ... /etc/hosts looks okay. ... getpeername means it doesn't have anything to connect with. ...
    (freebsd-questions)