sockets

Windows sockets

Hello everyone, Does windows closes idle sockets? I mean if I'm a client connecting to a service on Windows server, is it possible that Windows server closes the connection after certain idle-time? If yes, how to change this behaviour, or at least change the idle-time value? Thanks in advance. ...

How to find the port number of the caller of a web service in ASP.NET?

I have a web service that is running on IIS (6 or 7, doesn't matter) and I would like to know the port that the caller has sent their request/invocation from. So if a client makes a call on my web service, how do I find out from the server side what the port number is they made the call from? Is that something that even gets passed at ...

Linux to WinXP over UDP lag

I'm having a problem with a UDPSocket wrapper I've written. I have a high bandwidth low latency local network over which I'm sending UDP packets back and forth. I don't have a concern too much for reliability of packet arrival, but it is incredibly important that the packets that do arrive do so quickly. Here's the relevant code for s...

java.net.ConnectException: Connection refused when SocketChannel.open is invoked

Hi, I am trying to write a simple program to open a socket channel to a local address. I get a connection refused exception whenever I run this program import java.net.InetAddress; import java.net.InetSocketAddress; import java.nio.channels.SocketChannel; public class testSocket { public static void main(String [] args) { ...

In Cocoa, how do I set the TTL on a packet?

I want to be able to explicitly set the TTL value for a socket connection using Cocoa. I've been unable to see anything useful in the CoreFoundation docs. Do I need to go even lower to the BSD Sockets to set the TTL value? ...

Are nonblocking I/O operations in Perl limited to one thread? Good design?

I am attempting to develop a service that contains numerous client and server sockets (a server service as well as clients that connect out to managed components and persist) that are synchronously polled through IO::Select. The idea was to handle the I/O and/or request processing needs that arise through pools of worker threads. The sh...

Bind to any port available

I need an app that sends an UDP packet to some network server and receives the response. The server replies to the same port number where request came from, so I first need to bind() my socket to any UDP port number. Hardcoding the UDP port number is a bad idea, as it might be used by any other application running on the same PC. Is th...

How to make my PHP Socket Server send a policy file to flash clients?

My flash game needs to connect to my PHP Socket Server. Because of security things, a policy file has to be send to the flash client when it tries to connect. The following is what I've done. In Actionscript / Flex 3 / Flash: Security.loadPolicyFile("http://[SERVER.IP]:9000/crossdomain.xml"); socket.connect(hostName, port); //connect ...

iPhone socket program

I want to create an extremely simple iPhone program that will open a telnet session on a lan-connected device and send a sequence of keystrokes. Most of the code I've seen for sockets is overwhelming and vast overkill for what I want to do: open telnet socket to IP address send ascii keystrokes Any simple code examples out there I ca...

how to remove my chat's extra characters? C++

This my chat mixed with threads to run server and chat at same time. The problem is when I send a message to the chat lets say "Hello" as the first message, and "bye" as the second Output will go: Hello Byelo And some extra characters that I do not want there how to remove my chat's extra characters and letters? C++ I tried cout<<"Me...

Java's socket.localPort() always reports -1

I have some code which needs to know the local port it uses to connect to a server. The Socket.localPort() call always seems to return -1. Also, do a Socket.toString() returns something like "port=33031,localport=-1" - again, with a -1. Does anyone know why this, and how to get the local side port number? I am GNU Classpath 0.97.2 - i...

Socket Bind Error

Hi, I have a test application that opens a socket , sends something through this socket and then closes it . This is done in a loop for 5-10.000 times. The thing is that after 3,4000 iterations I get an error of this type : enter code here java.net.BindException: Address already in use: connect I even set the socket to be used immedi...

.NET NetworkStream Read slowness

I've got some network code to process an arbitary TCP connection. It all seems to work as expected but seems slow. When i've profiled the code the it seems to spend a good 600 ms in NetworkStream.Read() and I'm wondering how to improve it. I've fiddled with the buffer sizes and alternated between a massive buffer to read all of the dat...

boost::asio: How do I use async_accept to accept incoming connections?

I'm using boost::asio, and I have code like this: void CServer::Start(int port) { tcp::acceptor acceptor(m_IoService, tcp::endpoint(tcp::v4(), port)); for ( ;; ) { shared_ptr<tcp::socket> pSocket(new tcp::socket(m_IoService)); acceptor.accept(*pSocket); HandleRequest(pSocket); } } This code works, bu...

java socket server and embedded device - can't handle disconnect properly

I'm writing a server that is supposed to communicate with some embedded devices. The communication protocol is based on a fixed length header. The problem is I can't get my server to handle sudden disconnects of the devices properly (by "sudden" I mean situations when I just turn the device off). Here is the code for the client thread ma...

Is Socket.BeginReceive(IList<ArraySegment<byte>> buffers.. Not Asynchronous?

Hi all, I have been looking to implement a custom class of : IList<ArraySegment<byte>> this will be passed to a socket, and used as the buffer to receive data from that Socket. Socket.BeginReceive( IList<ArraySegment<Byte>>, SocketFlags, AsyncCallback, Object ) MSDN Documentation While testing I have found that when calli...

Object Not Garbage Collected

Hello All, I have a third party component I'm using and I'm seeing some issues with resources not being released. The component causes windows to create a handle to a UDP socket ("\Device\Udp" as well as "\Device\Afd"). If I allow the program to execute and dereference the third party object, I assumed that like all .NET objects I've ...

getsockopt() returns EINPROGRESS in non blocking connect()+select() flow [closed]

Update: My BAD. The error I am getting is ECONNREFUSED and not EINPROGRESS. After I had checked the %error% variable and found that it is greater than 0, I printfed errno instead of %error%. Of course errno is EINPROGRESS because it value didn't change since the call to connect(). Question answered. Thanks folks. I am using the the...

How to empty a socket in python?

I need to empty the data on a socket (making sure that there is nothing to receive). Unfortunately, there is no function for this in the python socket module. I've implemented something this way: def empty_socket(sock): """remove the data present on the socket""" input = [sock] while 1: inputready, o, e = select.sel...

.Net stop listening socket

I have a windows service written around some code similar to this Asynchronous Server Socket Example Everything works great. Client/Server communication works perfectly. No issues at all. When I try to shutdown the windows service, I can't stop the server socket listener without getting the following error: A request to send or r...