// client
#pragma comment(lib, "ws2_32.lib")
#include <WinSock2.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
//#include <sys/socket.h>
//#include <netinet/in.h>
//#include <netdb.h>
#define PORT 12345/*サーバと同じ数 */
int main(int argc, char *argv[])
{
WSADATA wsaData;
int i;
struct hostent *host;
struct sockaddr_in serv;
int s, n;
char buf[512];
WSAStartup(MAKEWORD(2, 2), &wsaData);
if (argc < 2) {
}
host = gethostbyname(argv[1]);
// bzero((char *)&serv, sizeof(serv));
memset(&serv
, 0, sizeof(serv
)); serv.sin_family = AF_INET;
serv.sin_port = htons(PORT);
serv.sin_addr = *(struct in_addr *)host->h_addr;
s = socket(AF_INET, SOCK_STREAM, 0);
i = connect(s, (const struct sockaddr *)&serv, sizeof(serv));
if (i < 0) {
// i = WSAGetLastError();
fprintf(stderr
, "cannot connect\n"); }
while (n = recv(s, buf, 512, 0)) {
}
shutdown(s, SD_BOTH);
closesocket(s);
WSACleanup();
return 0;
}
Ly8gY2xpZW50CiNwcmFnbWEgY29tbWVudChsaWIsICJ3czJfMzIubGliIikKI2luY2x1ZGUgPFdpblNvY2syLmg+CgojaW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1ZGUgPHN0ZGxpYi5oPgojaW5jbHVkZSA8c3RyaW5nLmg+CiNpbmNsdWRlIDxzeXMvdHlwZXMuaD4KLy8jaW5jbHVkZSA8c3lzL3NvY2tldC5oPgovLyNpbmNsdWRlIDxuZXRpbmV0L2luLmg+Ci8vI2luY2x1ZGUgPG5ldGRiLmg+CiNkZWZpbmUgUE9SVCAxMjM0NS8q44K144O844OQ44Go5ZCM44GY5pWwICovCgppbnQgbWFpbihpbnQgYXJnYywgY2hhciAqYXJndltdKQp7CglXU0FEQVRBCXdzYURhdGE7CglpbnQJaTsKCXN0cnVjdCBob3N0ZW50ICpob3N0OwoJc3RydWN0IHNvY2thZGRyX2luIHNlcnY7CglpbnQgcywgbjsKCWNoYXIgYnVmWzUxMl07Cgo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