Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. int server_socket = socket(AF_INET, SOCK_STREAM, 0);
  2. //connecting to the server with connect function
  3. send(server_socket, &datalength, sizeof(datalength)); //datalength is an integer containing the number of bytes that are going to be sent next
  4. send(server_socket, actual_data, sizeof(actual_data)); //actual data is a char array containing the actual character string data
  5.  
  6. int server_socket = socket(AF_INET, SOCK_STREAM, 0);
  7. //bind the socket to the ip and port with bind function
  8. //listen to the socket for any clients
  9. //int client_socket = accept(server_socket, NULL, NULL);
  10. int bytes;
  11. recv(client_socket, &bytes, sizeof(bytes);
  12. char* actual_message = malloc(bytes);
  13. int rec_bytes = recv(client_socket, actual_message, bytes);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement