*BSD News Article 36311


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!munnari.oz.au!spool.mu.edu!agate!ICSI.Berkeley.EDU!faerber
From: faerber@ICSI.Berkeley.EDU (Johannes Faerber)
Newsgroups: comp.os.386bsd.questions
Subject: socket(2)-Problem under FreeBSD
Date: 29 Sep 1994 23:40:23 GMT
Organization: International Computer Science Institute, Berkeley, CA, U.S.A.
Lines: 40
Distribution: world
Message-ID: <36fj97$can@agate.berkeley.edu>
NNTP-Posting-Host: icsib86.icsi.berkeley.edu

I try to transmit UDP-packets via my SLIP connection but I can't
bind a socket and thus only send packets, not receive them.

I use:

struct sockaddr_in sin;
[...]

hp = gethostbyname(hostname);
[...]

s = socket(AF_INET, SOCK_DGRAM, 0);
[...]

sin.sin_family      = AF_INET;
sin.sin_addr.s_addr = INADDR_ANY;
sin.sin_port        = htons(port);
bcopy(hp->h_addr, &sin.sin_addr, hp->h_length);
[...]

bind(s, &sin, sizeof(sin));
[...]

At compile time I get a warning for sendto, recvfrom and bind like
"passing arg 2 of 'bind' from incompatible pointer type". 

Even so, my send-program works fine but the receiveprogram tells
"bind: Can't assign requested address" and won't start.


What did I miss? The same code works for SunOs 4.1.3. What do I
have to do to make that thing run?

Any help will be appreciated,

Johannes


---------------------------------------------------------------------
Can I pay my VISA bill with my MasterCard?