Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Which one is faster than other? I am building a server-client app but I am not sure which one is faster. I can smoothly send and recive data with both but I want faster communication.
The NetworkStream is using sockets internally to operate. You can understanding by looking at the constructor of it in the Microsoft documentation.
public NetworkStream (System.Net.Sockets.Socket socket);
It provides you with methods that you can use to Read/Write to the stream easily.
The Socket class on the other hand provide you more control on what kind of data you want to exchange in the network. If you intent on exchanging data via TCP protocol in the network you will probably see no difference in the transfer speed by using Either Socket or NetworkStream.
If you need to exchange data with faster communication, consider using UDP protocol by using the Socket class but keep in mind that the UDP protocol is not connection oriented like TCP and no error checking occurs. As such you can't be sure of the reliability of your data and the guaranteed delivery of them.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am trying to do wireless communications between a PC and a Raspberry Pi using python's socket module. The problem is that the program on the PC is programmed in C# but the Raspberry-Pi is programmed in Python. How can I send a string from my computer so that the Raspberry Pi programmed in Python can read it?
A protocol like this is language-independent. That is one advantage of having such a concept.
If a server receives a connection request, it doesn't know or care what kind of code was used to create the connection and send the data (someone could even be typing it in by hand, in theory), all it cares about is that the data being sent is in the correct format (as defined by the protocol) and the messages follow the correct sequence etc, so that it can understand it.
This applies to all sorts of commonly-known protocols, such as TCP/IP sockets, or higher-level protocols which build on that, such as HTTP or FTP.
So as long as you know how to create code to initiate a socket connection in language A, and code to listen for connections in language B (or C or D, or even A again), then everything should work correctly.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
so, I'm super new to using an arduino, and I can't seem to understand what happens when I do SerialPort.Write() to one. like, what function within the standard firmata occurs?
When the computer sends data to the arduino trough a serial port, the arduino receives that data and stores it in a buffer until your arduino code does a Serial.read() (or any other variant used to read the serial data). Once the data is read, the buffer is cleared.
It's worth noting, however, that the handling of the usb comunication is NOT done by the arduino's main chip (the one in which your code runs), but rather in a separate chip installed on the arduino board solely for this purpose. The arduino library's Serial class handles the communication between the main chip and the one that handles the usb comms.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a project to create a messaging system for iOS, Android, web browser as the client. What kind of protocol can i use? I have read about the HTTP and Socket programming. Some solution that come up:
GET/POST HTTP
Socket
If we have the socket programming, how can we arrange the socket connection with the load balancing?
Any idea which one can I apply or other protocol?
Thanks
My first plan is to create something like a usual chatting app we know nowadays, but integrated with some other functions in the current system. Which one should I use?
I strongly recommend that you use an established protocol, IRC. For a general overview of IRC see http://en.wikipedia.org/wiki/Internet_Relay_Chat
Read about one Android library implementation at IRC library for Android (From 2.3.3 to 4.0.3 )?
This could go a long way towards solving your problem. Mainly though, "don't reinvent the wheel" as the saying goes.
You can check SignalR to use on the Website part. This will allow you to create real time connections. It uses WebSockets:
http://signalr.net/
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I am trying to build a chat app in c# that would work in the wan network.
There are 2 side in the app. Server side and client side.
In my thoughts i think that every message from client to client need to be passed to the server and the server will forward it to the right des client. The communications between the clients wont be directelly.
Is this the right model?
If yes, does the server need to have one socket that will listen to all clients? (Because every client sends his message to the same port at server).
Will the sever can handle management of million of messages on same port?
I think it is really up to what you want to accomplish, each choice has it's own pros and cons.
For example:
Using a centralized server can track messages , which users are online etc... but you will have to manage the ports for each connection (see explanation at the end of the answer for details).
Using a P2P model, you will not have the bottle neck and management required by the centralized server, but again it might be more of a hassle to manage a non centralized system (depends what exactly you want to accomplish).
If you are going to the centralized design, Typically You would have a server with a port that will listen for requests.
once a user wants to connect, the server will start a new thread for the client, and will assign a port for him (the thread will be typically from a thread pool and the port from a specific port range).
this will allow users to speak to the server in a non-blocking manner, and by that allow for multiple users to use the service simultaneously.
Take a look at SignalR and the chat system implemented using SignalR, Jabbr:
http://signalr.net/
http://about.jabbr.net/
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I'm creating a server that will in most/all cases be run on the same machine as the client. The client will need to be able to send and receive messages from this server. Some of the received messages will not be answers to questions (such as with http requests). All the messages will hold is a string that the project then uses to determine what function needs to be run.
The question is "Do I need to connect on two ports: one for sending and one for receiving?" If I use tcplistener with C# and C++ POSIX for networking, can I just send and receive messages on the same port?
Yes. You can send and receive on the same port and that's the intended way to communicate with tcp.
EDIT
You have two actors, a host and a client.
The host... will open a local network port (that you specify) and listen for new connections and communications from clients.
The client... can (and probably should) choose it's own local port and connect to the host on the port you specified.
Both the host and client... can communicate over the established connection. The host can send data to the client as long as the client is listening.
Have the server bind to and listen on a well-known port. Have the client bind to any port (you can let bind pick for you) and connect to the server on its port. Exchange messages.
Yeah, there isn't a difference between tcp/ip.