hehe, i need help, this code compiles on Dev-C++ but when i am running it i get an error, when i recieve the pass attempt thing
Code:
#include <iostream>
#include <fstream>
#include <winsock2.h>
#define PORT 23
#define BACKLOG 5
using namespace std;
int main(int argc, char *argv[])
{
ofstream iplogs("iplogs.txt", ios::app);
int clientlen, i, bytes;
char *idnumber = NULL, *loggered = "We have logged your IP as: ", *ask = "\nID: ", *pass = "chikka";
WSADATA wsaData;
WSAStartup(MAKEWORD(1, 1), &wsaData);
SOCKADDR_IN ourinfo;
ourinfo.sin_family = AF_INET;
ourinfo.sin_port = htons(PORT);
ourinfo.sin_addr.s_addr = htonl(INADDR_ANY);
SOCKET sock;
sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
bind(sock, (SOCKADDR *)&ourinfo, sizeof(ourinfo));
listen(sock, BACKLOG);
SOCKET newconn;
SOCKADDR_IN client;
clientlen = sizeof(client);
newconn = accept(sock, (SOCKADDR *)&client, &clientlen);
cout << "Got connection from: " << inet_ntoa(client.sin_addr) << endl;
send(newconn, loggered, strlen(loggered), 0);
send(newconn, inet_ntoa(client.sin_addr), 13, 0);
iplogs << inet_ntoa(client.sin_addr) << endl;
send(newconn, ask, strlen(ask), 0);
recv(newconn, idnumber, strlen(idnumber), 0);
if(stricmp(idnumber, pass) == 0)
{
send(newconn, "Welcome to the Super Computer\n", 31,0);
}
else
{
send(newconn, "hehe, idiot\n", 13, 0);
}
cout << endl << idnumber;
closesocket(sock);
closesocket(newconn);
WSACleanup();
return 0;
}