sockets

HTTP 1.1 Persistent Connections using Sockets in Java

Let's say I have a java program that makes an HTTP request on a server using HTTP 1.1 and doesn't close the connection. I make one request, and read all data returned from the input stream I have bound to the socket. However, upon making a second request, I get no response from the server (or there's a problem with the stream - it doesn...

What is the quickest way to detect an unreachable host in Java?

I would like the fastest and most accurate function boolean isReachable(String host, int port) that passes the following JUnit tests under the conditions below. Timeout values are specified by the JUnit test itself, and may be considered "unreachable." Please note: All answers must be platform-independent. This means that InetAddress.is...

I can't connect to my server over the internet

I can run the server on my local machine and connect to it on the same machine, but when i try to connect to it from a different computer over the internet, there is not sign of activity on my server, nor a response from the server on the computer im testing on. Ive tried both XP and vista/turn off firewalls/opened ports/run as admin; no...

java connection to jabber

What type of stream I need to use to write a connect request message over a tcp socket, to jabber. I'mwriting a string with xml format. It should worked with the default socket stream or a dataoutputstream but it doesn't. ...

How do I use raw sockets in Perl?

How can you get a raw socket in Perl, and then what's the best way to built a packet for use with it? ...

How do you find a free TCP server port using Ruby?

I'm trying to create a use-once HTTP server to handle a single callback and need help with finding a free TCP port in Ruby. This is the skeleton of what I'm doing: require 'socket' t = STDIN.read port = 8081 while s = TCPServer.new('127.0.0.1', port).accept puts s.gets s.print "HTTP/1.1 200/OK\rContent-type: text/plain\r\n\r\n" + t...

Is it possible to convert between Socket and TcpClient objects?

Here's another C#/.NET question based merely on curiousity more than an immediate need ... If you had a Socket instance and you wanted to wrap it in the higher-level TcpClient class, is that possible and how would you do it? Conversely if you have an instance of TcpClient, is it possible to get the underlying Socket? ...

Receive socket size limits good?

I am writing a program in Python that will act as a server and accept data from a client, is it a good idea to impose a hard limit as to the amount of data, if so why? More info: So certain chat programs limit the amount of text one can send per send (i.e. per time user presses send) so the question comes down to is there a legit reason...

C# streaming sockets, how to separate messages?

Kinda long title, but anyways... I've been looking at these examples, specifically on the parts on writing and reading the size of the message to the byte streams http://doc.trolltech.com/4.4/network-fortuneclient-client-cpp.html http://doc.trolltech.com/4.4/network-fortuneserver-server-cpp.html But I can't seem to figure it out in C#....

How to Create a TCP socket connect using C to a predefined port

Hi, I have a very simple question. I want to test whether a particular port is currently under use or not. For this, I want to bind a TCP socket to the port, if the connection is refused means the port is in use and if not that mean the port is free. Can someone please tell me how can I write the TCP socket code in C? I am on a solaris...

First-chance exception at <addr> in <myapp>: 0x000006BA: The RPC server is unavailable

What does it mean: "First-chance exception at in : 0x000006BA: The RPC server is unavailable" ? this debug message appears in Debug output of visual studio debugger when I using socket connection, but I don't know what operation initiates this message... ...

TCP connection quality in .NET

I have a mission-critical real-time data application that uses a TCP connection between the client and server. In some cases, the connection periodically dies (SocketException). No problem - just reconnect and move on. However, the customers aren't thrilled with these intermittent drops in connectivity. I'd like to know where to point t...

How to discard incoming packets in raw socket?

I'm writing a C/C++ application under Linux that reads data from a raw socket (for ICMP packets). Question: is there a way to discard all data that is still queued on the socket? The problem is that after sleeping for a while, there is data queued up on the socket which I'm not interested in; so it would be best to just tell the socket ...

I’m stunned: weird problem with python and sockets + threads

I have a python script that is a http-server: http://paste2.org/p/89701, when benchmarking it against ApacheBench (ab) with a concurrency level (-c switch) that is lower then or equal to the value i specified in the socket.listen()-call in the sourcecode everything works fine, but as soon as put the concurrency level in apache bench abov...

Is it possible to set a timeout on a socket in Twisted?

I realize I'm probably just dumb and missing something big and important, but I can't figure out how to specify a timeout in twisted using reactor.listenUDP. My goal is to be able to specify a timeout, and after said amount of time, if DatagramProtocol.datagramReceived has not been executed, have it execute a callback or something that I...

UdpClient, Receive() right after Send() does not work?

Hi, Consider the following code: client.Send(data, data.Length, endpoint); byte[] response = client.Receive(ref endpoint); While, according to WireShark (network sniffer), the remote host does reply with data, the application here just waits for data forever... it does not receive the answer from the remote host for some reason. Any...

cherrypy not closing the sockets

Hi Guys, I am using cherrypy as a webserver. It gives good performance for my application but there is a very big problem with it. cherrypy crashes after couple of hours stating that it could not create a socket as there are too many files open: [21/Oct/2008:12:44:25] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0',...

Java RMI not closing socket after lease expiration

My RMI enabled application seems to be leaking sockets. I have a Java application providing a service over RMI. It is using the Java SE 1.6 RMI implementation running on Linux. The problem I am observing is that if a client obtains a reference to my Remote object, using the Registry, and then the connection is severed abruptly (power ...

create Raw socket in Android

Hi, Has any body tried creating Raw socket in android and have succeeded. Please let me know. regards Harish ...

How do you throttle the bandwidth of a socket connection in C?

I'm writing a client-server app using BSD sockets. It needs to run in the background, continuously transferring data, but cannot hog the bandwidth of the network interface from normal use. Depending on the speed of the interface, I need to throttle this connection to a certain max transfer rate. What is the best way to achieve this, p...