FreeBSD Bugzilla – Attachment 247055 Details for
Bug 275774
IPv4 Mapper address problem
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
udptest_recv
udptest_recv.c (text/plain), 999 bytes, created by
Emmanuel Vadot
on 2023-12-15 12:25:34 UTC
(
hide
)
Description:
udptest_recv
Filename:
MIME Type:
Creator:
Emmanuel Vadot
Created:
2023-12-15 12:25:34 UTC
Size:
999 bytes
patch
obsolete
>#include <sys/types.h> >#include <sys/socket.h> >#include <netinet/in.h> >#include <arpa/inet.h> >#include <stdio.h> >#include <string.h> > >int main() { > struct sockaddr_in sa4 = { 0 }; > struct sockaddr_in sa4recv; > > int optval = 0; > int sock; > char buffer[20] = { 0 }; > > sa4.sin_family = AF_INET; > sa4.sin_port = htons(1234); > sa4.sin_addr.s_addr = htonl(INADDR_ANY); > > sock = socket(AF_INET, SOCK_DGRAM, 0); > > if (bind(sock, (const struct sockaddr*)&sa4, sizeof(sa4)) < 0) { > return -1; > } > for (;;) { > socklen_t len = sizeof(sa4recv); > int n = recvfrom(sock, (char*)buffer, sizeof(buffer), MSG_WAITALL, (struct sockaddr*)&sa4recv, &len); > if (n > 0) { > char ip_str[INET_ADDRSTRLEN]; > if (inet_ntop(AF_INET, &(sa4recv.sin_addr), ip_str, INET_ADDRSTRLEN) != NULL) { > printf("message %s received from %s\n", buffer, ip_str); > } > sendto(sock, buffer, n, 0, (struct sockaddr*)&sa4recv, len); > } > } > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 275774
:
247054
| 247055 |
247056