Created
August 14, 2013 06:28
-
-
Save ozuma/6228493 to your computer and use it in GitHub Desktop.
Send a UDP Packet. (C Code)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <sys/types.h> | |
| #include <sys/socket.h> | |
| #include <netinet/in.h> | |
| int | |
| main() | |
| { | |
| int sock; | |
| struct sockaddr_in addr; | |
| sock = socket(AF_INET, SOCK_DGRAM, 0); | |
| addr.sin_family = AF_INET; | |
| addr.sin_port = htons(50001); | |
| addr.sin_addr.s_addr = inet_addr("192.168.184.227"); | |
| sendto(sock, "HELLO", 5, 0, (struct sockaddr *)&addr, sizeof(addr)); | |
| close(sock); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment