1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- #include <stdio.h>
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <string.h>
- #define STR(num) #num
- int main(){
- int clientSocket, portNum, nBytes;
- char buffer[1024];
- struct sockaddr_in serverAddr;
- socklen_t addr_size;
-
- clientSocket = socket(PF_INET, SOCK_DGRAM, 6454);
-
-
-
-
-
-
-
-
-
- while(1){
-
-
-
- nBytes = strlen(buffer) + 1;
-
-
-
-
-
- nBytes = recvfrom(clientSocket,buffer,512,0,NULL, NULL);
-
-
-
-
- printf(STR(buffer)": ");
- for (int i = 0; i < 512; ++i) {
-
-
-
- printf("%i, ", buffer[i]);
-
- }
- printf("\b\b\n");
-
-
- }
- return 0;
- }
|