Re: Přijímání UDP paketů na OS AIX
Mailinglists
mailinglists at nocomment.sk
Thu Aug 28 19:45:41 CEST 2003
ssize_t
recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr
*from,
socklen_t *fromlen);
If from is non-null and the socket is not connection-oriented, the
source
address of the message is filled in. fromlen is a value-result parame-
ter, initialized to the size of the buffer associated with from, and
mod-
ified on return to indicate the actual size of the address stored
there.
treba doplnit pred volanim recvfrom teke ze l = sizeof(struct sockaddr_in);
pochybujem ze to na linuxe chodi.
----- Original Message -----
From: "Pavel Just" <just at ais.cz>
To: <net at cs.felk.cvut.cz>
Sent: Friday, August 15, 2003 9:24 AM
Subject: Přijímání UDP paketů na OS AIX
Zdravím.
Snažím se pod AIXem napsat krátký program, který udělá něco podle
toho, odkud přijde udp paket. Bohužel mi volání recvfrom strukturu
o klientovi zatvrzele navyplňuje. Co je špatně na následujícím zdrojáku ?
int test3(void)
{
struct sockaddr_in s,k;
int fd,r;
unsigned char buf[2048];
socklen_t l;
memset(&s, '\0', sizeof(s));
memset(&k, '\0', sizeof(k));
k.sin_family=AF_INET;
s.sin_family=AF_INET;
s.sin_addr.s_addr=inet_addr(INADDR_ANY);
s.sin_port=htons(8000);
fd=socket(AF_INET,SOCK_DGRAM, 0);
r=bind(fd,(struct sockaddr *)&s, sizeof(s));
r=recvfrom(fd, buf, 2048, 0, (struct sockaddr *)&k, &l);
printf("%d\n",l);
return r;
}
Struktura k se nikdy nenaplní a l je nula :(. Pod linuxem to chodí.
Pavel Just
--
-----------------------------------
Tato zpráva neobsahuje viry, protože nepoužívám MS Windows.
More information about the net
mailing list