Skip to main content
Share Your Experience: Take the 2024 Developer Survey
30 votes
Accepted

Simple and effective port checker in C++

Checking TCP ports and multi-threading Your performance should be fine for a sequential program. Another way to check whether the TCP port is open is by just sending the initial ...
Zeta's user avatar
  • 19.3k
18 votes
Accepted

C++ Linux TCP client/server socket wrapper

Design This is a very thin C like wrapper around sockets. In my opinion there are a lot of style changes that are need to make this good C++ or usable by modern C++ library. Main issues: Two phase ...
Martin York's user avatar
  • 95.2k
16 votes
Accepted

C Socket Part-1

I can't resist saying this… the way you use a lot of whitespace to achieve your horizontal alignment, especially in server.cpp, is distracting and hinders ...
200_success's user avatar
14 votes
Accepted

Python bot to answer mathematical questions for a remote server

My main concern is the use of eval() without proper validation (well, the regular expression extraction puts some limits onto the possible ...
alecxe's user avatar
  • 17.3k
12 votes
Accepted

A Simple C++ Client That Sends Data Over TLS Using OpenSSL

C++ review You still need a C review! Idioms/Patterns RAII idiom In C++ we have this concept that an object should clean up its own resources. So when an object is created it will create and hold onto ...
Martin York's user avatar
  • 95.2k
11 votes

C Socket Part-1

One of the issues with TCP sockets is that there's no guarantee that sending N bytes in one go will result in receiving exactly N bytes after one call to read(). I ...
D. Jurcau's user avatar
  • 3,010
11 votes
Accepted

struct sockaddr_storage initialization by network format string

Am I using too many comments? No. Am I using too much register variables? Yes. The register keyword is completely obsolete these days. It was intended as an ...
Harith's user avatar
  • 6,992
10 votes

Python bot to answer mathematical questions for a remote server

I'd prefer to see more safety, more structured code, and more abstract symbols instead of magic values. There is some inefficiency due to repeated calls that should be cached. Safety You're ...
aghast's user avatar
  • 12.4k
10 votes
Accepted

Network Interface Object

There is no guarantee that write writes out the entire buffer. This means that ...
vnp's user avatar
  • 56.5k
10 votes

Network Interface Object

the posted code causes the compiler to output several warning messages. When compiling, always enable the warnings, then fix those warnings. Here is the compile statement and the resulting warning ...
user3629249's user avatar
  • 2,818
10 votes
Accepted

Python scanner for the first free port in a range

Your code has some incorrect assumptions. an application may listen on a specific address/port combination; 127.0.0.1:port can be available while ...
Oh My Goodness's user avatar
10 votes
Accepted

Simple HTTP Server

Note: This review focuses on the use of C++, rather than the functionality. Naming: IMHO, the use of "do" at the start of function names is unnecessary and makes the code harder to read. The names ...
user673679's user avatar
  • 11.8k
10 votes

struct sockaddr_storage initialization by network format string

Use getaddrinfo() Instead of using inet_ntoa(), getservbyent() and similar low-level ...
G. Sliepen's user avatar
  • 57.3k
10 votes

Simple TCP port scanner

From atoi()'s man page: BUGS errno is not set on error so there is no way to distinguish between 0 as an error and as the ...
Harith's user avatar
  • 6,992
9 votes
Accepted

Follow Up: struct sockaddr storage initialization by network format-string

Why not always use getaddrinfo()? I kept the version with struct sockaddr_storage anyway Why? It is inferior in every possible ...
G. Sliepen's user avatar
  • 57.3k
8 votes

PlayerConnection class for Gaming Emulator

Private functions & fields aren't called/modified within the class: ListenForPackets is private and isn't called by ...
8 votes
Accepted

Correctly applying the "rule of five" to a RAII socket wrapper

These are good questions! 1. You should indeed have the copy constructor & assignment operator deleted. The "rule of five" tells you to specifically define a copy c'tor and assignment ...
einpoklum's user avatar
  • 2,015
8 votes

Follow Up: struct sockaddr storage initialization by network format-string

There's a subtle mistake in this macro definition: #define ARRAYSIZE(x) (sizeof(x) / sizeof(x[0])) When we put parens around the expansions of macro arguments, ...
Toby Speight's user avatar
8 votes
Accepted

Simple TCP port scanner

Skipping blocked ports quickly It is possible to reduce the timeout for connect() when trying to connect to unresponsive ports, by setting the ...
G. Sliepen's user avatar
  • 57.3k
7 votes

C Socket Part-1

Some issues that occur to me: The obvious problem is that there is no error checking. memset is often preferred to bzero, ...
William Morris's user avatar
7 votes
Accepted

Unix chat server making communication between terminals possible

Portability The code uses pthread which is a POSIX (Portable Operating System Interface) structure. If the code uses POSIX for one thing, it might be better to use <...
pacmaninbw's user avatar
  • 23.8k
7 votes

Follow Up: struct sockaddr storage initialization by network format-string

Declare only where needed: //long port; //port = strtol(*str, (char **) str, ...); long port = strtol(*str, (char **) str, ...); Simplify initialization: ...
Harith's user avatar
  • 6,992
7 votes

Follow Up: struct sockaddr storage initialization by network format-string

Two minor points about this bit: #if(_POSIX_C_SOURCE != 200112L) #undef _POSIX_C_SOURCE #define _POSIX_C_SOURCE 200112L #endif First, if you define ...
Davislor's user avatar
  • 7,546
6 votes

Server socket "wrap" functions

NO. NO. NO. NO. This does not do you any good none at all. In fact I think this is worse than doing nothing. All you have done is created a new layer that provides no advantages over the old and ...
Martin York's user avatar
  • 95.2k
6 votes
Accepted

C++ Socket Part-2

A public non-virtual destructor in a base class is risky. You should consider making it protected, or otherwise virtual, if ...
glampert's user avatar
  • 17.1k
6 votes
Accepted

Async TCP client/server

Async/Await Async/await's main advantage is that you no longer need to use ContinueWith() to chain tasks, making the code much cleaner. Your code seems to more ...
D. Jurcau's user avatar
  • 3,010
6 votes
Accepted

Sending a file over a socket with AES encryption

try-with-resources ...
mdfst13's user avatar
  • 21.6k
6 votes

Multithreaded C# TCP Socket Server

I am kinda new to reviewing code but I know c# kind good and will try my best. First, let's go over some code style issues. At the top you declared variables like this: ...
Patrick Hollweck's user avatar
6 votes

The start of a Python port scanner

Is there a better container type to use for GENERATED_ADDRESSES other than a list? You could use a set() this will save time with comparing if the ...
Ludisposed's user avatar
  • 11.6k
6 votes
Accepted

Socket server in c#

configuration is usually accessed statically I have a different impression. Configuration is accessed in a way that is convenient in terms of maintainability and testing. And static references do not ...
Nikita B's user avatar
  • 13k

Only top scored, non community-wiki answers of a minimum length are eligible