s = socket(AF_INET, SOCK_STREAM, 0);
/* ... */
memset(&client_addr, 0, sizeof(client_addr));
client_addr.sin_family = AF_INET;
client_addr.sin_port = htons(22222);
if (bind(s, (struct sockaddr *) &client_addr, sizeof(client_addr)) < 0) {
perror("bind");
exit(1);
}
connect(s, (struct sockaddr *) &server_addr, sizeof(server_addr));