Click here to Skip to main content
15,867,594 members
Everything / TCP/IP

TCP/IP

TCP/IP

Great Reads

by Espen Harlinn
A .NET Core client implemented in C# using TcpClient and a multi-threaded server implemented in C++
by pdoxtader
Learn how to view a remote machine's file system using your own explorer like window, and transfer files and folders by dragging and dropping in C# using the TcpComm TCP library
by bkelly13
Goal: Describe how asynchronous or non-blocking TCP code works
by Dan Randolph
Builds on the existing RunRemote project to run commands on a remote server.

Latest Articles

by Patrick Eckler
Example of a TCPIP server that listens and can serve multiple client connections
by Mirzakhmet Syzdykov
Network programming in C++
by Espen Harlinn
A .NET Core client implemented in C# using TcpClient and a multi-threaded server implemented in C++

All Articles

Sort by Score

TCP/IP 

23 Mar 2021 by Espen Harlinn
A .NET Core client implemented in C# using TcpClient and a multi-threaded server implemented in C++
19 Sep 2019 by pdoxtader
Learn how to view a remote machine's file system using your own explorer like window, and transfer files and folders by dragging and dropping in C# using the TcpComm TCP library
14 Sep 2018 by bkelly13
Goal: Describe how asynchronous or non-blocking TCP code works
23 Dec 2011 by Dan Randolph
Builds on the existing RunRemote project to run commands on a remote server.
1 Aug 2017 by Andy Galluzzi
NAT traversal for Software Developers
22 Dec 2011 by thatraja
Too many questions in your question, anyway I found this article in CPIserver Cyber Cafe[^]And Codeproject has a section for Hardware and System[^] related articles.Use CP & Google for more.EDITControlling PC And Remote Access via lan in c#[^]Manipulate remote machine control...
15 Dec 2010 by EFEaglehouse
Windows CE/Mobile printing client for LPR, LPRng, and Socket API.
17 Jan 2011 by dasblinkenlight
In my experience, running your client in a virtual machine on the same computer as the server lets you simulate real-world client-server environments very realistically. Our company used VMWare's and Microsoft's virtualization products for debugging and in QA; both worked very well for our...
12 Mar 2011 by Espen Harlinn
The following is in c# - but it's about as simple as it gets.Introduction to TCP client server in C#[^]Without a TCPListener you have to actively poll the server for data, on its own, the TCPClient does not listen for incomming requests.Use something like ThreadPool[^] to poll data...
12 Jun 2011 by #realJSOP
You could add a "command header" to the beginning of your byte array that is comprised of a known length, say 64 or 128 bytes or even larger (to give you room to grow). Then, you just plug in your command/param values into that area. As long as both the sending and receiving apps are aware of...
3 Jun 2012 by Shahin Khorshidnia
HelloLook at this:Sharing data among Windows Forms. Especially this part: "Is there a way to send a message back to the server from the client?"
15 Jun 2010 by Chris Maunder
In some unix flavours you can emulate a slow network connection to, say 4KB/s usingsudo ipfw pipe 1 config bw 4KByte/ssudo ipfw add 100 pipe 1 tcp from any to me 80Is there an equivalent in Windows?
16 Jan 2011 by Ashish Tyagi 40
First of all check whether your app is connected to internet using this link.. can you see me[^] put your listing port no and hit check button..If it failed probably you are listnig on 127.0.0.1(localhost) or your LAN address (like 192.168.0.10)so change your listing interface address to...
9 Apr 2011 by krishkr
There are a lot of things I'm trying to understand here. I don't want to read through entire book volumes or articles, just the possible solution to the condition mentioned below. Also, I couldn't find the answer in the forums I have seen. Please direct to me a concise answer if available. The...
11 Jul 2012 by Mehdi Gholam
Communication between two programs will work irrespective of the UI technology used, one could be a console app (usually the server when testing) and the other can be any technology (WiForms, WPF, WEB etc.).For an object orientated TCP library take a look at my article WCF Killer[^]
26 Oct 2013 by Zoltán Zörgő
1) Learn your lessons. We don't do homework.2) Look here: http://nmap.org/book/images/hdr/MJB-TCP-Header-800x564.png[^]3) This is incomplete. The header is at least 20 bytes long. You had given only 6. The first two questions can be answered (80; http), but for the third one, you need the...
30 Jun 2014 by Sergey Alexandrovich Kryukov
With TCP, there is absolutely no difference where how sending data is directed: from client to server or from server to client. The connection is always established by the initiative of the client, which is connected to the listening server, and this is the only reason why a client is a client...
5 Apr 2016 by Jochen Arndt
You are writing ClientSocket.ReceiveBufferSize bytes to the file here:FileStreamer.Write(bytesFrom, 0, CInt(ClientSocket.ReceiveBufferSize))even when you have received less bytes. You must use the number of bytes that has been actually received instead which are returned by...
22 Oct 2018 by Jason Gleim
Few things... Socket programming beyond the trivial examples can be confusing so here is what you need to know. 1) Your RFID reader needs to open a connection to the server on a specific port. So you reader should be programmed to send messages to 192.168.1.12 on port 9999. In your code...
20 Jul 2010 by Richard MacCutchan
From your description it would appear that your client needs two parts.The sender portion should create an arbitrary socket which connects to the server port 4001 and communicates as necessary.The client also needs a listener socket bound to port 5001 which will accept connections from...
20 Jul 2010 by Aescleal
If you accept the general definition that a server is something that listens for a connection you haven't really got a straight client and server here... Both what you're calling your client and what you're calling the server are actually both clients and servers.So your "server": -...
9 Sep 2010 by CodingBruce
When you want an application to trigger on an event (timer, system, file, etc.), but you don't want the overhead of the service manager
30 Sep 2010 by ARopo
Depends on your deploymentEverything on the same machineEverthing on a LANEverthing over a WANOver the internetFastest would be tcpip, but this would present firewall problems if over a WAN. Regarding crashing on high load that would depend on how well your software and...
4 Nov 2010 by OriginalGriff
This is very simplified - I ignore packet overhead, acks, response turnround, switch backplane capacity, and unicode.2KB = 2096 * 8 bits.100 messages per second = 100 * 2096 * 8.500 clients = 500 * 100 * 2096 * 8.= 838,400,000 bits per second.Are you using a gigabit network?...
28 Dec 2010 by Aman4.net
Dear cyberm0t0,I would like to tell that while you are using database in your project you need to write ConnectionString in your code to establish connection. No other settings are required.Best place to write ConnectionString is Web.config (in Web Project) and App.config (in window...
3 Jan 2011 by Rod Kemp
What you need is to look at port forwarding/port triggering on the LAN the server is connected to.What port forwarding does is when a connection attempt is made to a specific port on the public IP of the LAN the server is on the connection request get forwarded to the server, the forwarding...
4 Jan 2011 by Espen Harlinn
This should get you started:Simple Chat Application Using .Net Sockets[^]Usually only the server needs a "fixed" port. Here is one alternative:If you want your clients to activly listen to a port on the client machine, you probably need to store this information in a central database...
5 Jan 2011 by Emilio Garavaglia
in a scenario like A--->proxy --------proxy
16 Mar 2011 by Espen Harlinn
If you can't use open source libraries - like ACE[^], you obviously have to roll your own alternative.Check out the POSA2 book, Patterns for Concurrent and Networked Objects[^]Patterns are recipes on how to implement functional software based on successful implementations.Best...
6 Apr 2011 by DonTone
Hi,I have a simple question about a problem that surely someone has already encountered. I have a legacy device that communicates (communicated) with another device through RS-485. It does this with its own protocol, which is quite simple and embedded in there are raw ARP, IP, TCP, etc...
23 Dec 2011 by Sergey Alexandrovich Kryukov
My first advice is: don't use any asynchronous APIs if a synchronous API is available. Yes, it will need blocking calls, but you place it in a separate thread. I think asynchronous APIs used to make some sense (still questionable) when threads were not a commonplace, but these days threads are...
5 Jan 2012 by Sridhar Patnayak
Dear Abhishek ,Transmission Control Protocol is a connection-oriented protocol, which means that it requires handshaking to set up end-to-end communications. Once a connection is set up user data may be sent bi-directionally over the connection. So if the network is VPN,Lan or Intranet,...
8 Feb 2012 by Jonathan [Darka]
In TCP/IP you typically have a static or dynamic IP address but you need to know the port number... so what do you mean by dynamic port?
18 May 2012 by emranallan
Server Application to remote your mobile device through wireless/wire connection not based on RAPI
29 Aug 2012 by fjdiewornncalwe
Either launch 2 instances of Studio and debug them both at the same time, or bring both the client and server projects into one solution in which case you can run them both at the same time in 1 debug session there.
10 May 2013 by Sicppy
A DLL resource to help beginner to intermediate developers open and use sockets in a P2P application.
11 Nov 2013 by OriginalGriff
The "s" at the end of IPInterfaceProperties.DnsAddresses is a clue that there may be more than one, and the MSDN documentation backs that up: http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ipinterfaceproperties.dnsaddresses(v=vs.110).aspx[^]It's a Collection: just...
30 Nov 2013 by OriginalGriff
Data alignment is the simple answer.A char is a single byte, so it can be aligned on an odd or an even byte boundary - the address of the character can be odd or even.Generally speaking any datatype which is not byte long needs to be aligned on an even address (or longer depending on the...
12 Dec 2013 by Sergey Alexandrovich Kryukov
Why?! Create a separate thread to work with each separate telnet server and work synchronously. Synchronize those threads using thread synchronization in those rare cases when it is needed.I think asynchronous APIs get popularity when threads were not a commonplace, or just because many...
3 Jan 2014 by Rob Philpott
I think this line is the problem:int receivedBytesLen = clientSock.Receive(clientData);In that I think you are expecting to receive the whole data sent in this single call. It doesn't work like that (I've been caught out myself with this). This will return the data in chunks as it is...
8 Jan 2014 by Ravi Bhavnani
You should educate yourself on the general principles of client-server apps - that would help you design a solution. There's no need to create multiple servers. A single server that offers multiple services (e.g. for chat, for retrieving a poker hand, for making plays, etc) will suffice./ravi
5 Feb 2014 by Sergey Alexandrovich Kryukov
The discussion in comments looks going well beyond the format of Quick Questions & Answers. You really need to design the server and client parts thoughtfully from the very beginning; so focusing on just your questions may not be so helpful. For some very relevant ideas, please see my past...
9 Oct 2015 by George Jonsson
I would not recommend using threads the way you are using them in your code, instead take a look at these examples on MSDN:Asynchronous Client Socket Example[^]Asynchronous Server Socket Example[^]I have based some applications running on different machines on these examples and...
23 Mar 2016 by Jochen Arndt
Your program requires that a port number is passed on the command line. So pass that when starting it:myserver 5001Alternatively you can hard code the port number by changing the code as suggested by CPallini. But then you have to comment / remove the line getting the port number too://...
31 Mar 2016 by Jochen Arndt
Your server sends initially the image size as integer and it is received by the client and stored in the variable size.What is printed by your client when it receives the size?According to the linecout
22 Aug 2016 by Jochen Arndt
You are using blocking sockets. When receiving and there are no more data, the recv function will block (not return) until new data are received or the connection is closed (as triggered with your third try).The simplest method to avoid this is using some kind of indication that all current...
7 Nov 2016 by Albert Holguin
Well, if you're not sure, TCP/IP should usually be your default go-to. That's because it has a lot of neat built-in overhead that's very useful, such as retransmissions and error checking, that UDP doesn't have. UDP should be used when you need high-speed transmissions where you don't mind...
8 Sep 2017 by OriginalGriff
We can't tell you: you should talk to the people who created it - they should provide technical support and will know more about their product than we will. If they don't, then find another supplier and demand your money back! SDK support is up to them, not us!
17 Jul 2020 by k5054
For one thing, it should be clntsock.sin_addr.s_addr = hton(INADDR_ANY); Here's a function that will create a socket that listens for connections to get you going: int init_socket_on_port(unsigned short port) { struct sockaddr_in serv_addr;...
15 Jun 2010 by _Damian S_
Several different methods are discussed here[^] however they are all to do with testing websites... assuming this is what you want to do, you could probably find one you like!
15 Jun 2010 by PSK_
Chris,In my last project I was trying to setup a slow network to test the website performance but I didn’t succeed, due to some policy restriction I was not able to install the 3rd party software.I am not sure if any inbuilt tool available in windows for this, but definitely there are...
27 Jul 2010 by Daniel Moos
YourTCPClient....
30 Sep 2010 by EhsanShemirani
I am looking to achieve the fastest and scalable communication between several servers. I've developed a custom TCP socket server for this purpose with (IOCP) as I think it would be the fastest communication in .NET, but I don't know if it crashes on high load, or if my solution is the fastest...
4 Nov 2010 by Anthony Mushrow
I believe that even if you have enough bandwidth to cope with the amount of data you want to send, there's too much overhead and latency with sending that many packets. When sending over TCP you need to send the packet which will have a small delay as it gets sent onto the actual network...
20 Nov 2010 by jim lahey
Streaming with WCF might be for you:[http://msdn.microsoft.com/en-us/library/ms731913.aspx]
3 Jan 2011 by Espen Harlinn
Take a look at MSMQ..Net API[^]C/C++ API[^]Otherwise you can always create your own communication system using the Windows Socket 2 API[^]Or use Windows Communication Foundation[^]RegardsEspen Harlinn
11 Jan 2011 by Baji Jabbar
From the question what I understood is you need a Windows service to check the value in the TCP/IP port. Web service need to be invoked always.If you want the Web service to do the checking use the windows service to invoke the web service , which ( Web Service) in turn do the checking and...
16 Jan 2011 by Seyed Hamed Khatami
Hi!I made a program using the socket class in C# which is a chat program. In LAN network I can work with it, but over the internet I can't.Can you guide me?Thanks in advance!
17 Jan 2011 by ad_robot
Hi Everyone, I'm implementing asynchonous socket programming in (C++, winsock, TCP/IP, based on this example Chat Client Server[^]) at the moment (for data streaming) and am running into problems with missing data when I run the code over a network rather than locally (I only seem to recieve...
31 Jan 2011 by Sergey Alexandrovich Kryukov
First, if this is TCP, why not using a bit higher-level TcpListener class? Do you always have one client or more? With TcpListener you can permanently listen to new connections on one thread and work with client (or clients) on another. On client side you could use TcpClient. Just the idea, very...
8 Apr 2011 by Sergey Alexandrovich Kryukov
Do you mean your local ports? You need to scan all the local ports in the set you're interested in.Here is the code illustrating the idea:http://social.msdn.microsoft.com/Forums/en/netfxnetcom/thread/8f0e0f22-a2d2-43f5-9909-d491297f4337[^].Sorry if I did not understand what did you...
20 May 2011 by HimanshuJoshi
If you want to just capture and see the data on a specific port, use Wireshark[^]. Or if you want to create a program that captures specific TCP traffic, use Winpcap[^] library.
8 Jun 2011 by Kim Togo
You have to thing about that TCP is like a pipe where data can be transported in. On top of that, you can implement what ever protocol or message system you like.Say you what to send and receive a file. Then you have to tell the receiver some information about that file you will sent. It can...
21 Jul 2011 by lewax00
Do you mean like writing to /dev/null in Linux? If so Windows has a file called nul in system32.
12 Sep 2011 by MaulikDusara
Hi,Multi-thr...
24 Oct 2011 by BobJanova
Obvious question: do you ever close the connection at the other end?NetworkStream.Read will return 0 if and only if the connection has been terminated (otherwise it will block until there is at least one byte). So check for that in your loop condition. Read will also never read more than the...
31 Oct 2011 by Espen Harlinn
I think you need to look at BinaryReader Class[^]and BinaryWriter Class[^]I cannot make changes to the server codeUse the above classes to serialize/deserialize the messages according to the format dictated by the server.You need to determine how many bytes are used for each field, and...
31 Oct 2011 by Sergey Alexandrovich Kryukov
Please see my comment to the question. A will assume you mean .NET vs. C++, not C++/CLI. If both sides are .NET, there are no problems whatsoever. All code and serialization mechanism are platform-wide in .NET, they are not specific to language. Also, in .NET serialization is fundamentally based...
25 Nov 2011 by Richard MacCutchan
As described here[^] the TCP packet includes a checksum. Whether that is sufficient for your requirements is another matter.
26 Dec 2011 by Mehdi Gholam
You can do so by creating separate threads for each port, and listening and processing the data on that thread.You can also create and run separate processes for each port, or run the same program with different command lines.
9 Jan 2012 by BobJanova
This is almost certainly the wrong approach. Port numbers are a precious resource and if you have control over the protocol, it is much better to only listen on one, well known port and have the first message in the protocol be a switching message that chooses further details of future messages...
13 Jan 2012 by Sergey Alexandrovich Kryukov
Please see my comment to the question. I can also give you some basic idea and the skeleton of right design I tried to explain in my past solution:Multple clients from same port Number[^].If something is not clear, feel free to ask your follow-up questions. The key here is accepting a...
19 Jan 2012 by Simon Bridge
I have a question for all those security boffins out there.I am developing a Tcp/Ip based client/server system that needs to be VERY secure.I'd like to know if there are any obvious vulnerabilities in the way the system works.Each communication is initiated by the client, the server...
19 Feb 2012 by iKrshnan
I am trying to send data from a C#.NET (Windows Application) program to a Java (Android App) program and vice versa, via TCP connection through Wifi. Till now I am success to send data from Java to C#, but unable to do so from C# to Java.Following is the Java code, I used to create a...
1 Mar 2012 by Richard MacCutchan
Use a structure[^] and just add the fields you want into it. As long as both client and server use the same structure you should be able to do what you want. The general protocol of your message would then be to send the fixed length structure first, which will contain, at least, the length of...
26 Mar 2012 by Shahin Khorshidnia
HelloLook at these please:Controlling Windows Firewall using C# via COM InteropHow to check if external firewall is enabled?Detect if windows firewall is blocking my program?In C#, how to check if a TCP port is available?How to detect if my IP Address is blocked by ISP...
1 Apr 2012 by Rin San
Hello,I'm trying to build a Server\Client program which allows me to transfer multiple files simultaneously between my laptop and home computer. I found in an article that an asynchronous connection allows you to do that, so here's what I've done so far:The Servernamespace...
22 Aug 2012 by Kuthuparakkal
using System.Net;using System.Net.NetworkInformation;using System.ComponentModel;using System.Threading;using System.IO;namespace PingMyServer{ public static void Main(string[] args) { //if (args.Length == 0) //throw new...
21 Aug 2012 by uspatel
Use Ping and PingReply classhttp://www.shefeekj.com/ping-ip-address-using-cnet.html[^]
18 Sep 2012 by Grant Curell
IP checksum implementation in python
26 Sep 2012 by himanshupareek
Parse the PCAP dump and extract NETBIOS and DNS queries.
25 Oct 2012 by Dave Kreskowiak
You don't do any of this in your code.The internal machine that is the target of the port forwarding configuration should be using a static IP address (explicitly entered) OR use DHCP and on the DHCP server, configure it to give out a reserved IP address to that machine every time it asks...
25 Oct 2012 by barneyman
I think you may want to look at the UPNP Protocol[^]That's the accepted way of devices/PCs on a private LAN negotiating dynamic port forwarding with the routerThat's how the Xbox and BitTorrent clients (for example) can all accept incoming connections without you setting anything up on...
6 Jan 2013 by Christian Graus
If you go to the various stock market websites, you can find out how they share their data on the web. The rest is a pretty basic application, any basic tutorials will help you from there.
6 Jan 2013 by ridoy
Some business related application development tutorial in below link.You can see those which will match to your requirement..http://www.c-sharpcorner.com/1/207/[^]
21 Jan 2013 by CPallini
MODBUS is a relatively simple protocol. The first two entries of a Google quick search are two useful documents: I've got the CRC implementation (C source code) from the first one: "ModiconModbus Protocol - Reference Guide"[^] and used the second one, namely: "MODBUS APPLICATION PROTOCOL...
21 Jan 2013 by Jibesh
Quote:I have read the manual and it says it supports Modbus/TCP, TCP, UDP protocols which means you can communicate with the device though sockets to read/write data to it. The normal procedure is go through their manual on how to configure your device, the manual will also have sample...
6 May 2013 by Ron Beyer
If you don't think the Arduino is good, maybe try .NET Gadgeteer, that way you can develop both sides in C# which has a lot of code examples and code base to work from.Take a look at www.ghielectronics.com
17 May 2013 by GAJERA
Hi AllI have to trace the HTTP traffic .It work without Https. I try for the https, it successfully get the response via Sslstream through the certificate. When i forward ssl response for the relay but it doesn’t getting the response.Please let me how to relay SSL response?Please check...
31 May 2013 by Jiří Miklík
Using one socket for many threads isn't best idea.My suggestion:Each client thread opens own connection, server thread is listening.With this solution you can find the end of client thread with error (socket dies).And you cannot distribute opened socket to client threads at start time.JiMi
20 Jun 2013 by StM0n
Hello,@"more than one port": Sure, you could do that; but if you use a firewall between your endpoints, you have to open the ports.@"server performance": Depends on the usage of different application pools for your services.Just my two cents :)
14 Jul 2013 by Joezer BH
See:socket-bind-returns-th...
7 Sep 2013 by Dave Kreskowiak
Considering you haven't described anything at all about what type of application your talking about (Windows Forms, ASP.NET, WPF), what your application does, where it runs, if there is client and server sides to it, if it uses some database, what database engine that is, capacity information on...
17 Sep 2013 by nv3
You may call recv in a loop. It will block when no data are available and return only when data has been received or a socket error has occurred.If your program has other things to do in parallel while you are waiting for the next data package to arrive, then you should run the receive loop...
18 Sep 2013 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
SolutionIf you want to know whether the user read your mail or not, then follow the below technique.Add one image with with dimension 0px*0px inside the mail HTML.On src attribute of image, provide one aspx page link.On Page_Load of that aspx page, you can write any code to...
30 Sep 2013 by Richard MacCutchan
Then you need to go and search[^] for the items you are interested in.
1 Oct 2013 by Maciej Los
M.S.S.E wrote:(...)how set up such a connection (...)I need (...) a complete guide to setup (...)It doesn't work like this! This is a place where you can get a quick answer, not complete guide. Please, use Google with statements:Oracle enable tcp/ip connectionsHow to setup...
15 Oct 2013 by Sergey Alexandrovich Kryukov
It's not that this property is not "yet" implemented; such implementation would not make any sense. Think about the nature of network streams: a remote part writing to the stream can always write some more data. Also note that the stream is the abstraction behind the sequence of TCP packets, so,...
24 Oct 2013 by Jochen Arndt
For each block of data you are sending from the client to the server, your server answers by sending the block number and the client waits for this packet before sending the next block of data. These packets slow down the overall throughput.You may remove them and send one status message...