bassosimone/libight — pull request #25 by bassosimone (2014-09-11 06:54:26+00:00)
Title: Stop using long long to represent sockets

Libight used `long long` to represent sockets. This is a libneubot legacy; I needed a socket representation that was converted by SWIG into a Java native type (`long long` was converted to `jlong`).

Since the SWIG-and-Java requirement is gone, we can reduce complexity by using libevent's socket type, i.e., `evutil_socket_t`. This change is implemented by this pull request.

I could have removed everything that was related to `long long` sockets. However, I think there was a value in the sockets range checking code (given that Windows and Unix have different socket representations). For this reason I decided to keep that piece of code, and I adapted it to the new scenario in which sockets are `evutil_socket_t`.

At a first glance it seems useless to keep Win32 compat code around, yet I am seriously thinking of using libevent to implement Neubot's uTP test, and Neubot also runs on Windows. This is to say that I have a concrete Win32 use case.

This pull request increased my awareness of how sockets are represented by Unix, Windows and libevent; it also includes a unit test that makes sure there are no breakages. Speaking of the tests, this pull request also adds a test for `net/connection.{cpp,h}` that for now only deals with the bits touched by this pull request (more tests would have been out of scope).