tcp

tcp connect timeout (unix/windows portable)

I'm using perl (which hopefully shouldn't affect anything), but I need to know how I can set a timeout for the connect operation. The problem is I can't wait forever for the connect operation to happen. If it doesn't happen within a few seconds, I'd rather give-up and move on. socket(my $sock, PF_INET, SOCK_STREAM, (getprotobyname('tc...

Making a TCP connection through a restrictive outbound firewall

I'm using Java to create a client/server application that communicates using TCP. The network that the client is running on has an outbound firewall that prevents the client from connecting to the server. Is there any way/workaround to create a TCP connection through this firewall? I have tried to use common ports that are open such as ...

How can a WCF service listen the same port as IIS?

I could run a Windows Service hosted WCF service listening http://localhost:80/MyService while IIS was serving pages on http://localhost:80 and both works. But many places in the internet (like this and this) say that only a single process can listen each port simultaneoulsy. Are they wrong? ...

Listening for TCP connections through a browser

Is there some sort of method I could use to launch something from a browser which would listen for tcp connections? I explored Silverlight but it looks like I can only connect to 3rd parties with a Silverlight app. What I'm looking for is have the user run something in browser which could receive third party connections. I'm starting ...

command line connect to tcp port, read data, match pattern, print true or false

I'm trying to write a monitoring script. It should connect to some port on my server. Read the output. If the output is the expected value, print 1, otherwise print 0. I'm working on a solution involving cat < /dev/tcp/hostname/port, but the solution eludes me. Maybe something involving expect? Prefer a bash script solution. Help appreci...

how to print flags in TCP header of raw packets using libpcap

Hi all , sniffex.c is a program that is based on libpcap , to sniff and display some packet information. How do i modify it so as to print the values of TCP flags - urg , ack , psh , rst , syn and fin ? please help.. ...

Simple networking help (C# WinForms)

Hi All I'd like my app to be able to communicate with itself via the internet but this is proving to be impossible for me. One thing I've never been able to work out is Tcp or the whole networking thing in general. I have read the docs and seen literally over 30 samples, none of which have ever worked. All I'm trying to do is send a m...

monitor incoming/outgoing http traffic with .net

I want to write a small application that can: 1. monitor URLs requested via a web browser and/or 2. monitor incoming http responses on the local machine I have been doing some Googling, but I am not finding any clear answers. I am thinking maybe System.Net.Sockets.TCPListener and messing around with it, but I am under the impression t...

How does client-machine/browser handle unrequested HTTP response?

Imagine the following: User goes to script (http://sample.org/test.php), Script sends an HTTP request to some other page (http://google.com/). For this example, we'll say using curl. The script sets the IP address of the request to the user's IP, via CURLOPT_INTERFACE. I know already that the requesting script will not receive the re...

Can 2 WCF service processes listen the same port?

I know 2 processes can't listen the same port, but as it happens with HTTP requests in the port 80, I know Windows can receive the packets and reroute to the appropriate services. I just don't know if it also happens with other ports and protocols (net.tcp for instance). ...

What would be the Spring way of using TCP connections?

I am reading and write XML over a TCP connection (not HTTP) as part of a web service I'm developing, and I was wondering whether there is a more "springified" way (or even other ideas) of achieving what I'm trying below: InputStream is = null; OutputStream os = null; Socket s = null; try { s = new Socket(address,...

accept() method and tcp/ip handshake

I use java ServerSocket class for server application. Does accept() method participate in tcp/ip handshake? As I see in tcp/ip dump and from command netstat, clients establish connections with before accept method is called and return Socket object. Is it java issue, or I do not understand accept() semantics? ...

TCP connection reset occurs when WSGI app responds before consuming environ['wsgi.input']

For our webservice, I wrote some logic to prevent multipart/form-data POSTs larger than, say, 4mb. It boils down to the following (I've stripped away all WebOb usage and just reduced it to plain vanilla WSGI code): import paste.httpserver form = """\ <html> <body> <form method="post" enctype="multipart/form-data" action="/"> <in...

What is easiest way to send structured data via tcp using java?

I have to connect to a existing C system, and the tcp packet looks like typedef struct exampleDataPacket{ int messageType; float dataValue; char dataDesc[100]; } So to send this kind of data using java, I can't find anything in my books. What would be the best way to send/receive this kind of data? Thanks, CP ...

What are some tips for buffer usage and tuning in custom TCP services?

I've been researching a number of networking libraries and frameworks lately such as libevent, libev, Facebook Tornado, and Concurrence (Python). One thing I notice in their implementations is the use of application-level per-client read/write buffers (e.g. IOStream in Tornado) -- even HAProxy has such buffers. In addition to these a...

Test harness software for networking failures

During integration testing it is important to simulate various kinds of low-level networking failure to ensure that the components involved properly handle them. Some socket connection examples (from the Release It! book by Michael Nygard) include connection refused remote end replies with SYN/ACK but never sends any data remote end se...

Creative use of MarshalByRefObject

I've been banging my head trying to figure some things out. So, I'm looking for advice and research material (via links). Here's the scenario: We have a library (say, CommonLib) that contains resources needed by several other applications (say, AppA, AppB, AppC, and so on...). Now, the way this is currently working is AppA instances, ch...

C# Stopping TCP File Transfer

Hi, I'm programming simple TCP file transfer using TcpListener on reciever side and TcpClient on sender side. I have 2 options - synchronnous or asynchronnous. If I use synchronnous, I have to put sending/recieving methods into BackgroundWorker, to prevent freezing GUI thread. Asynchronnous version is without problems... My question is,...

Qt: Python tcp client sends data over socket. How to read these bytes with Qt ?

Situation: I have tcp client made with Python and tcp server made with Qt. I try to send bytes with my client but I can't get Qt server to read these bytes. Using Python made client and server, everything works fine. Also I can get my Python client work with C# server with no problems. Code for Python client: import socket import sys...

read and write thread using a single tcp socket

Hi, I'm using a C socket library I found online to implement a tcp socket data transfer program. Is it possible to make 2 threads share the same socket connection (1 read and 1 write), and have the read thread perform a blocking read and recv data while the write thread constantly writes data? All of the example socket programs I've se...