First, just to get the program ready to compile, I made the listed changes:
Quote:
// Use appropriate headers
// Changed to winsock2, more recent
// Added std namespace using directive
// Typo or copy error: SOCKET_ERRO R changed to SOCKET_ERROR
// Made all "main" paths have a return
|
For C++, the .h headers were provided for backward compatibility, are deprecated, and should not be used. I haven't any knowledge of "H-less" replacements for winsock or windows. My includes look like this:
#include<winsock2.h>
#include<windows.h>
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<fstream>
//#pragma comment(lib,"wsock32.lib")
using namespace std;
In the following line, you are outputting from an uninitialized thangy, "from".
cout<<"<server IP: "<<inet_ntoa(from.sin_addr)<<"> "<<'\n';
I realize style is purely a personal thing, except when dictated by bosses/clients. Nevertheless, I'd ask if you write your emails and such without spaces between tokens. Clarity is an important plus and my personal opinion and experience is that the effort expended is not time wasted. Remember that ultimately a lot of our code is produced by habit. Best not to let the bad ones accumulate unduly.
I'll continue to look at the functionality of the code, thought I'd just drop the results of the initial whack on you.