Gast
#3435273
hallo ich möchte einen chat programmieren wo der client (programmier ich
später) auf den server eine nachricht sendet und der server sendet das
dann auf den 2. client hier mein code bis jetzt:
#include <windows.h>
#include <conio.h>
#include <iostream>
#include <string>
int main() {
using namespace std;
string fehler;
int port;
string erfolgreich;
string falsch;
string viels;
//ip adresse
char hostname[255];
char *szIPAddress;
WORD wVer;
WSADATA wData;
PHOSTENT hostinfo;
wVer = MAKEWORD( 2, 0 );
if ( WSAStartup( wVer, &wData ) == 0 )
{
if( gethostname ( hostname, sizeof(hostname)) == 0)
{
if((hostinfo = gethostbyname(hostname)) != NULL)
{
szIPAddress = inet_ntoa (*(struct in_addr *)*hostinfo->h_addr_list);
}
}
WSACleanup();
}
cout<<"deine ip ist: "<<szIPAddress<<endl;
cout <<"bitte port eingeben!" <<endl;
cin >> port;
cout <<endl;
cout << "server port: " << port <<endl ;
cout<<"bitte Taste dr\x81 cken"<<endl;
getch();
viels = "viel spass!";
falsch = "der befehl ist nicht korrekt";
erfolgreich = "alles ging erfolgreich!";
fehler = "bitte kontaktiere einen server administrator um den fehler
zu beheben!";
cout << erfolgreich <<endl << viels <<endl;
bool slotsfrei;
slotsfrei = true;
if(slotsfrei == true)
{
cout << "es sind server slots Frei!";
}
else
{
cout << "es alle Server Slots besetzt!";
}
}