taron_31 | Re, désolé, je ne peux pas envoyer la banniere LOGIN au client qui vient de se connecter :
Code :
- #include <winsock2.h>
- #include <windows.h>
- #include <iostream>
- #include <stdio.h>
- #include "need.h"
- #pragma comment(lib, "ws2_32.lib" )
- using namespace std;
- DWORD WINAPI ClientThread(LPVOID);
- DWORD WINAPI CheckThread();
- int main(int argc, char *argv[])
- {
- WSADATA wsaData;
- WSAStartup(MAKEWORD(2, 0), &wsaData);
- int i = 0;
- if(argc < 2)
- {
- cerr << "Usage: messenger <port>\n";
- return 0;
- }
- if((sockd = socket(AF_INET, SOCK_STREAM, 0)) == SOCK_ERROR)
- {
- cerr << "Socket() error:" << GetLastError() << endl;
- return 0;
- }
- sin.sin_family = AF_INET;
- sin.sin_port = htons(atoi(argv[1]));
- sin.sin_addr.s_addr = inet_addr("127.0.0.1" );
- if((bind(sockd, (SOCKADDR *) &sin, sizeof(sin)) == SOCK_ERROR))
- {
- cerr << "Bind() error: " << GetLastError() << endl;
- return 0;
- }
- listen(sockd, MAX_CLIENT);
- for(; i < MAX_CLIENT ; i++)
- {
- int len = sizeof(sin);
- system("cls" );
- cout << "Number of client : " << i;
- if((sock[i] = accept(sockd, (SOCKADDR *) &csin[i], &len) == INVALID_SOCKET ))
- {
- cerr << "Accept() error: " << GetLastError();
- }
- hThread[i] = CreateThread(0, 0, &ClientThread, reinterpret_cast<LPVOID>(i), 0, 0);
- if((send(sock[i], LOGIN, 100, 0)) == -1)
- {
- cerr << "Send() error: " << GetLastError() << endl;
- }
- }
-
- return 0;
- }
- DWORD WINAPI ClientThread(LPVOID param)
- {
- return 0;
- }
- DWORD WINAPI CheckThread()
- {
- return 0;
- }
|
apres je vous fout la paix promis !
Merci beaucoup |