Skip to main content
5 votes
Accepted

How do you resolve a byte[] into a class instance in a way that doesn't couple the serialization/deserialization contexts together

The short answer is that you have to provide sufficient metadata to allow the receiver to recognize what to do with the message data.  You want some approach that supports extensibility and loose ...
Erik Eidt's user avatar
  • 34.8k
5 votes
Accepted

How to efficiently solve "close" players/items in an online game without iterating through all of them?

The standard approach is to divide your world up into large squares/cubes and keep track of which each player is in. You can then iterate over the players in the square the player is in, rather than ...
Ewan's user avatar
  • 84.4k
5 votes
Accepted

Why does an POST request from HTML/JavaScript generates 401(unauthorized) but it doesn't from a C program?

CORS (Cross-Origin Resource Sharing) Simply allowing javascript to access any network resource is Not a Good Idea TM. Usually javascript is downloaded from a server (not here but out there), but it ...
Kain0_0's user avatar
  • 16.6k
4 votes

UDP order of packets with direct connection

It is possible. I have observed such behaviour on direct connection (no hub or switch) between two machines. In my case it happened only when application sent datagrams one after another without any ...
user305241's user avatar
3 votes

How do you resolve a byte[] into a class instance in a way that doesn't couple the serialization/deserialization contexts together

The fundamental basis of communication is that the sender wants the receiver to reach a desirable state (otherwise why would the sender bother?). To achieve this the sender must send a message that ...
Kain0_0's user avatar
  • 16.6k
3 votes
Accepted

Where is the difference with client-socket port and server-socket port?

Why we need to open port for server on router, and allow to connect from the outside, but doesn't for client ? If the router performs a network address translation function to translate between the ...
Bart van Ingen Schenau's user avatar
3 votes
Accepted

Scaling tcp/ip socket server applications

I would recommend looking at distributed pub/sub frameworks. Even if you decide to implement it yourself with TCP/IP instead of using the framework, their architecture should still provide inspiration....
Samuel's user avatar
  • 9,247
3 votes

Proper way to send custom data structures by sockets

If you want to send data via sockets, you are best off converting the data first to some textual format (like JSON, or XML). A significant problem with sending binary data over the internet is that ...
Lewis Pringle's user avatar
3 votes

What are the possible *root causes* of a SocketTimeoutException?

To be honest, a socket times out when the server or client fails to respond within the timeout limit. There are many varying causes for this. The only thing you know for certain is that: The server ...
Berin Loritsch's user avatar
2 votes

Do TCP Sockets need validity/security checks?

TCP guarantees that packets will arrive at your application in order - that's one of the main differences between TCP and UDP. If necessary, the TCP stack will buffer up out-of-order packets, and re-...
Simon B's user avatar
  • 9,782
2 votes

Why does an POST request from HTML/JavaScript generates 401(unauthorized) but it doesn't from a C program?

Because that's not allowed in Javascript. Javascript runs in a sandboxed environment; there are a lot of things you are not allowed to do there, such as write to the user's file system. You can ...
Robert Harvey's user avatar
2 votes

Are all sockets implemented as per the Berkeley sockets specification?

No, Berkeley Sockets are not the only networking API. The Wikipedia article you linked to lists a couple of alternatives. The most notable ones are STREAMS, which appeared in Research Unix 8 and are ...
Jörg W Mittag's user avatar
2 votes

Prioritizing messages sent over a socket

There are a lot of details to consider in evaluating the effectiveness of the 5-socket approach and whether a single socket can have equivalent behavior. First, look at the existing system: Is the ...
Hans-Martin Mosner's user avatar
2 votes

Possible microservice based design

I will share a few of my thoughts but please take my word lightly. Microservise's size A microservice can be as big as it needs to be. I remember reading about the pizza rule once, which said that a ...
Cap Barracudas's user avatar
2 votes

Optimising network data usage in vehicle tracker

Perspective Some back of the envelope calculations to put things into perspective: Let's assume that handling a single such request consumes 2 kB of data. That's 24 kB of data per minute, 1.44 MB ...
jaskij's user avatar
  • 575
2 votes

Is my server design safe regarding multiple threads and concurrent database reads/writes?

Databases have been designed to be accessed from multiple threads for a long time. Try googling about how to use transactions in databases that should help you on how to ensure consistency in the face ...
lijat's user avatar
  • 121
2 votes

What are services and interfaces of a layer in a computer network model?

Are the HTTP methods (e.g. GET, POST) services or interfaces? Neither. Possibly both. Each layer performs some services for the layer above it. The service definition tells what the layer does, not ...
Useless's user avatar
  • 12.9k
2 votes

Is it more secure to develop libraries in-house than using existing libraries?

Encryption is most commonly defeated not by cracking it, but by going around it. Misconfigured or poorly implemented encryption solutions will defeat even the latest snazziest security schemes. Given ...
candied_orange's user avatar
2 votes

Linux poll with a thread pool and multiple events

Here is the crux of your problem: App-level record boundaries matter to your app. TCP PSH (segment push) events won't necessarily correspond to record boundaries. As with everything else in computer ...
J_H's user avatar
  • 7,891
1 vote

How best to structure this MVC or Razor Pages web application given a required tcp/ip server data source that acts like a web api?

My first idea would be to write a small proxy for this pseudo web api. The proxy should be whitelisted so it can contact the listener and it would handle the authentication and authorization of ...
Bart van Ingen Schenau's user avatar
1 vote
Accepted

Asynchronous Server in C++

with C++ it appears as if it is basically mandatory to use ASIO not at all. That's just a cross-platform library which gives you nice, portable code. You can always code directly to your platform ...
Useless's user avatar
  • 12.9k
1 vote

How should I handle dealing with a stream of incoming data?

Google "log drain". There are vendors who will consume your data - and then make the data available via queries on a web site application. If you have a lot of data it gets expensive. Some ...
Emmett's user avatar
  • 11
1 vote

Chat part of application - using UDP or TCP?

I would highly recommend integrating your application to an existing chat solution. Whether you use Slack, Jabber, or any other robust chat solution you no longer have to worry about the persistence ...
Berin Loritsch's user avatar
1 vote

Chat part of application - using UDP or TCP?

Please review carefully the suggestion made by Robert Harvey, above. TCP requires you to "open a socket" and then guarantees two-way ordered conversations. If you send three packets, they will all ...
Mike Robinson's user avatar
1 vote

How do you resolve a byte[] into a class instance in a way that doesn't couple the serialization/deserialization contexts together

A design that requires disambiguation by default, I'd consider broken unless there was a specific reason to do so. Now, are these objects completely orthogonal or are they polymorph? By polymorph I ...
Martin K's user avatar
  • 2,947
1 vote

Instant Messaging with WebSocket

the second approach sound better than the first 1 although i wont use it. dealing with a data base when loading a lot of messages on your servers might be time consuming. the best solution for this ...
Dev93's user avatar
  • 21
1 vote

What are the limitations of WinSock2 sockets within threads?

I figured it out on my own, though I would like to clarify that based off of Microsoft documentation, my unrevised code should have worked in both circumstances (or not worked in both circumstances). ...
KeatonB's user avatar
  • 129
1 vote
Accepted

(C++) Ideal design pattern for associating requests/responses on socket?

Your buffer of all callbacks is basically unavoidable, I'd not be much concerned about it. The required size will depend on the expected number of outstanding requests at any time, not on the total ...
Hans-Martin Mosner's user avatar
1 vote

Which is better approach - using subprocess vs communicating over socket?

On the surface, it looks like your trade-off is between performance and complexity. Performance As you point out, there's added performance costs to executing a subprocess. Complexity For the 3rd-...
Matthew's user avatar
  • 1,115
1 vote

Which is better approach - using subprocess vs communicating over socket?

It depends. Using a subprocess is probably simpler/easier to implement, but like you've said, will probably perform more poorly than reusing a single process for multiple requests (there may also be ...
Bwmat's user avatar
  • 808

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