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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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....
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 ...
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 ...
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-...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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).
...
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 ...
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-...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
sockets × 135networking × 26
java × 20
tcp × 17
c++ × 15
c × 12
c# × 11
multithreading × 10
websockets × 10
python × 9
server × 9
client-server × 8
networks × 8
design × 7
node.js × 7
http × 6
android × 5
linux × 5
protocol × 5
design-patterns × 4
architecture × 4
.net × 4
database × 3
javascript × 3
php × 3