Okay then, in my free time I came up with another little project.
It involved using networking as obvious.
So I thought... What if I write a little Socket library for my projects, so I could re-use it?
I also thought I could make it public, so people could see and test.

To the point:
Source Code:

Built Windows Executable:

All the most variating things are in the namespace Implementation (in Sockets.cpp).
Sockets.cpp will only compile on Windows for the moment, but it's quite easy to change it to be unix compatible.
(Mostly: From InetNtop/InetNtopA to inet_ntop, the includes in Sockets.h, and the error constants)

Functions like Implementation::connect and so on, are just there for secondary operating systems.
They should not harm anything as the compiler will certainly inline those calls.

Requires C++11's:

Hope this helps someone, or at least pops a bug to be fixed.

Usage of the executable file:

You first input an address to connect to
(Input is in form or
Then you input the data to be sent to the host
(Some escape sequences are ready to be used like \r, \n, \t... NOT \x! But that's not the point.)
GET / HTTP/1.1\r\n\r\n

At this point, the program will connect and try to send the chosen input.
As soon as it ends sending, it will try to receive a reply.
Timeouts are in the Library, meaning you can choose a Timeout, the library itself can choose an automatical Timeout (Based on a chosen, fixed network speed, I chose 8KB/s, you can find it in Sockets.cpp as Implementation::ExpectedClientNetworkSpeed), or no Timeout at all (which chooses the highest possible timeout time).

Some other things I should take into consideration, especially while porting?
closed account (S6k9GNh0)
This seems rather similar to a telnet client.
The main.cpp is just for testing.
Also, the key presses are not sent over the network.
Instead the connection is created AFTER the inputs, so no timeouts could occur if a user types too slowly.
The main point of the topic was Socket.cpp/h tho.
Last edited on
Topic archived. No new replies allowed.