wie kann ich eine socketverbindung "annehmen" und einen string zurücksenden??
meine client programm in c++
gruss reima
meine client programm in c++
Code:
int connection(char Send[600]) { int rc; SOCKET s; SOCKADDR_IN addr; WSADATA wsa; WSAStartup(MAKEWORD(2,0),&wsa); s = socket(AF_INET,SOCK_STREAM,0); if(s == INVALID_SOCKET)return 1; else{MessageBox(0,"winsock erfolgreich gestartet","erfolg",0);} HOSTENT *he = gethostbyname ("reima.funpic.de"); memset(&addr,0,sizeof(addr)); addr.sin_addr.S_un.S_un_b.s_b1 = he->h_addr_list[0][0]; addr.sin_addr.S_un.S_un_b.s_b2 = he->h_addr_list[0][1]; addr.sin_addr.S_un.S_un_b.s_b3 = he->h_addr_list[0][2]; addr.sin_addr.S_un.S_un_b.s_b4 = he->h_addr_list[0][3]; addr.sin_family=AF_INET; addr.sin_port = htons(80);//wir verwenden mal port 80 char buf[600]; rc = connect(s,(SOCKADDR*)&addr,sizeof(SOCKADDR)); if(rc == SOCKET_ERROR){MessageBox(0,"error","error",0);} else{MessageBox(0,"verbindung zum server hergestellt","erfolt",0);} send(s,Send,strlen(Send),0); recv(s,buf,sizeof(buf),0); string x = buf; return 0; }
gruss reima
Kommentar