tcp

One's complement instead of just a sum of bits

A question in my university homework is why use the one's complement instead of just the sum of bits in a TCP checksum. I can't find it in my book and Google isn't helping. Any chance someone can point me in the right direction? Thanks, Mike ...

SSL_accept with blocking socket

I made a server with SSL and blocking sockets. When I connect with telnet (so it does not do the handshake), the SSL_accept blocks indefinitely and blocks every new handshake/accept (and by definition new connections). How can I solve this awful problem ? ...

How can I recreate an error where Network.CanRead is true and nothing is being sent

Related Question: http://stackoverflow.com/questions/1746342/networkstream-canread-true-but-buffer-returning-no-value I want to recreate a TCP server that doesn't send any data on the network stream (or that's how it seems when the bytes are converted to string) but the NetworkStream object .CanRead property still remains true If I don...

Rejecting a TCP connection before it's being accepted?

There are 3 different accept versions in winsock. Aside from the basic accept which is there for standard compliance, there's also AcceptEx which seems the most advanced version (due to it's overlapped io capabilities), and WSAAccept. The latter supports a condition callback, which as far as I understand, allows the rejection of connecti...

Long Lived Persistent TCP Connection on the Android

I've read some articles on the web and some questions on StackOverFlow, but no one seems to have a definite answer over a) If google uses Long Lived TCP connections for Gmail, Mail etc, and b) If using it in a custom app will drain battery life , and if so roughly how much? ...

Client/Server: Integer always received as 1 (C-programming)

Hi! I'm building a client and a server program that exchanges data over TCP and I'm having trouble sending an ACK-confirmation from the server back to the client when an operation is successfull. I've managed to send a struct with various members from the client to the server, then the server should respond by sending an integer confirm...

Checking a local TCP port is not open in Java

Is there a simple way to make sure that a local port is not already open. Some TCP socket servers (eg Grizzly) don't seem to do this check by default. When this check is missing, the server appears to start and respond, but the client code is just connecting to an old server that wasn't shutdown. This can be very bad! Is there a simp...

Restricting tcp communication to specific ip's using C#

Hi, I want to make a simple program that can restrict any communication over the internet except for some specific ip's. So that the user can eliminate any unwanted traffic. It has to be simple and the user must be able to switch it on and off on the fly. My first thought was to use Windows Firewall and set it up using C#/WPF. And it ...

[C#] What is the correct way to close a TCP connection

I have a TcpClient object which sends some data to server, using its underlying NetworkStream.Write(). Therefor, I have: TcpClient server = new TcpClient(serverName, 50001); /* ... */ NetworkStream stream = server.GetStream(); Now, when a button is pressed, the connection should close. What is the right way to close the connection? ...

what is best port for program

Which of the following ports is the best one to use for a program I'm working on using a custom protocol still under development. I'm looking for one that will be accessible to virtually every host that is connected to the public internet (ie every host that can view websites can use this port). The three main options are: port 53 udp ...

Problem in TCP Program (Java)

Can anyone help me debug this program? The following is server code : package networking; import java.io.IOException; import java.io.PrintWriter; import java.net.ServerSocket; import java.net.Socket; import java.util.Scanner; class TcpServer { public static void main(String[] args) throws IOException { ServerSocket server...

What limits the number of connections for a TCP port?

Lets say I have an application that is going to listen on a particular TCP port for a connection. Is there a theoretical limit on the number of connections that can be handled in the same port? Or is there only a practical limit based on the OS and other properties? I've searched the Internet but couldn't find a conclusive answer. Tha...

TCP Server not reading from socket untill objects disposed

Hi, Please excuse my choice of wording and/or mixup of terms, I am a dummy when it comes to socket programming. I am trying to connect to a TCP server, write a message and process a response. I use the following code: Dim tcpClient As Sockets.TcpClient = New TcpClient() tcpClient.Connect(hostname, 9080) Dim networkStream As NetworkSt...

Sending binaries in Erlang over TCP

Using the code below to send. The gen_tcp:send call returns {error,einval} but I can't figure out why... -define(TCP_OPTIONS,[binary, {active, false}, {reuseaddr, true}]). client() -> case gen_tcp:connect(to_Server(), 8080, ?TCP_OPTIONS) of {error, Reason} -> io:format("~p~n",[Reason]); {ok,My_Socket} -> Message ...

How can I find a TCP port that is free with NetTcpBinding (WCF) (so a server can bind to it)

Find the next TCP port in .Net says how to do this in raw .net, but not how to safely to this with WCF. In my unit tests, I need to use the NetTcpBinding, I do not wish to hard code the port it is using. Therefore how can I get the NetTcpBinding to automatically choose a free port when used in my ServiceHost? How can I get it to tel...

What is the cost of many TIME_WAIT on the server side?

Let's assume there is a client that makes a lot of short-living connections to a server. If the client closes the connection, there will be many ports in TIME_WAIT state on the client side. Since the client runs out of local ports, it becomes impossible to make a new connection attempt quickly. If the server closes the connection, I w...

Object serializing performance

Let's say I have a simple tcp server generating an array inside a thread, serializes it and sends it to a client over tcp connection and when it reaches the client, the client deserializes it and performs something...ie. continuous calculation. Well it's a pretty straight forward process but I would like to know if the process has any pe...

TCP Connection Persistent State

Is there any field/option/anything that I can put in a TCP packet (be it a syn or an ack or just plain data) that I can be sure will be returned by the other end intact? For eg. I want to "tag" a particular connection (src, srcport, dst, dstport) with a number that I can always read from a packet belonging to that connection. That means...

Skipping data in winsock?

Is it possible to skip a portion of the incoming data on a TCP stream socket, instead of having to read it into a buffer? Preferably, I'm looking for something that also works asynchronously. ...

Zero Window when sending files through posix sockets

Hi I have a problem - when I'm trying to send huge amounts of data through posix sockets ( doesn't matter if it's files or some data ) at some point I don't receive what I expect - I used wireshark to determine what's causing errors, and I found out, that exactly at the point my app breaks there are packets marked red saying "zero windo...