Hello all,
I am trying to send a few UDP packets and cant figure it fully out.
I am running under UNIX OpenBSD 4.2
Heres what I got so far.
I am trying to send a few UDP packets and cant figure it fully out.
I am running under UNIX OpenBSD 4.2
Heres what I got so far.
Code:
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <netdb.h> #include <sys/socket.h> #include <netinet/in.h> #include <netinet/in_systm.h> #include <netinet/ip.h> #include <netinet/tcp.h> #include <arpa/inet.h> int main() { int port = 1936; char addr[15] = "2.0.0.2"; // I know you intaililize the socket with socket sock = socket (AF_INET, SOCK_STREAM, 0); // This is where i get confused struct sockaddr_in addr; address.sin_family = AF_INET; //we're using inet address.sin_port = htons (port); //set the port connect (sock, (struct sockaddr *) &address, sizeof(address)) //Create the packet sprintf(packet, "La la la la"); //And send it write (sock, packet, strlen(packet)); close (sock); // Close the connection }
Comment