sockets

How can I get the interface name/index associated with a TCP socket?

Hi, I'm writing a TCP server that needs to know which interface each connection arrived from. I cannot use the address/subnet to deduce which interface was used, since there might be interfaces with the same address/subnet values. It's Linux based, and there's no need for the code to be portable. All I could find were functions to get ...

Netcat anomaly in VMWare/Cygwin/Sockets environment

I'm happily running Ubuntu Linux in a VMWare box hosted on XP. My Linux application opens up your basic server socket port, to which I connect netcat (nc) as a client to listen in on the traffic I'm putting on that socket for the "real" clients. All's well. However, when I open up a Cygwin shell on the XP side and run nc from there it ...

Which Interprocess Communication methods work on a Terminal Server?

In a terminal server session, some standard IPC technologies might not work like in a single user environment, because the required resources are not virtualized. For example, TCP/IP ports are not virtualized, so applications in different sessions which try to listen on the same port will cause a port conflict. Which IPC technology wil...

How can I check is a socket is still open?

I have a C++ app that uses standard socket calls and I want to know if I can tell if a socket is still open without sending or receiving any data. Is there a reliable select or ioctlsocket call I can make? ...

How to use the select() function in socket programming?

The prototype is: int select (int nfds, fd_set *read-fds, fd_set *write-fds, fd_set *except-fds, struct timeval *timeout); I've been struggling to understand this function for quite some time. My question is, if it checks all the file descriptors from 0 to nfds-1, and will modify the rea...

Java Socket Programming - Address already in use (errno=98)

Hi all, I'm try to write a basic server-client java application. However, I alway got a message of "socket bind on 10 for port 13244 failed: Address already in use (errno=98)" error no matter what port I'm using. I have attach a source code of my application, just wondering is there very stupid mistake I'm making. Many Thanks! Cheers...

.Net client vs Java Server with raw data

I am writting a .Net/C# client to a Java Server on Solaris. The Java server is writting Raw byte data in a Gziped format which I need to extract, but I am having trouble to read the data in the right buffer sizes. I read the message not-deterministicly incomplete or complete and can not read the second message in any case. I am reading ...

TCP socket timeout configuration

I have a Java application which uses a third-party COM component through a Java-COM bridge. This COM component opens a socket connection to a remote host. This host can take some time to respond, and I suspicious that I'm getting a timeout. I'm not sure because as I said, it's a closed-source third-party component. The API of this comp...

Is there a way to flush a POSIX socket?

Is there a standard call for flushing the transmit side of a POSIX socket all the way through to the remote end or does this need to be implemented as part of the user level protocol? I looked around the usual headers but couldn't find anything. ...

Need Help parsing stream data from php socket server with perl.

I'm working on a project for my company that uses a socket server (php) to gather data from a remote device. How can I make this perl program run directly on the stream instead of first having the server write to a tmp file then running this script on that file then writing out a csv file for insertion into a database? I thought about ...

Spurious readiness notification for Select System call

On http://linux.die.net/man/2/select, under BUGS section it is mentioned that the select system call may sometimes spuriously set the FD ready and the subsequent read call will return 0. The text describes one such example (wrong checksum) but I am assuming there would be other reasons too (otherwise they would have fixed this). Any id...

How can I achieve non-infinite receive and send timeouts on a socket under Compact Framework?

On full .Net Framework I use the following code: socket.SetSocketOption( SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, readTimeout); socket.SetSocketOption( SocketOptionLevel.Socket, SocketOptionName.SendTimeout, writeTimeout); However, Windows Mobile does not support this and throws exceptions. I am currently in the...

What's up with the Adobe AIR HTML development socket reference?

I'm trying to reconcile the various Adobe AIR HTML guides, and am totally lost. I want to do something with a socket. Some general guides on the topic here and here refer to Air.Socket(); But the supposedly Adobe AIR HTML reference looks like it's not even JavaScript and it references a namespace (window.runtime.flash.net.Socket) that ...

How to find the other point of a Unix domain socket on Mac OS X to write/read it?

Hello everyone, I listed open file for a process (a daemon) on my box which runs Mac OS X 10.5 : >lsof -p 89 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME ... xxxxx 89 xxxxxxxx 9u unix 0x34f8990 0t0 ->0x34f8880 I 'd like to find a way to open this socket and write in it. (that's my obsession...

If a nonblocking recv with MSG_PEEK succeeds, will a subsequent recv without MSG_PEEK also succeed?

Here's a simplified version of some code I'm working on: void stuff(int fd) { int ret1, ret2; char buffer[32]; ret1 = recv(fd, buffer, 32, MSG_PEEK | MSG_DONTWAIT); /* Error handling -- and EAGAIN handling -- would go here. Bail if necessary. Otherwise, keep going. */ /* Can this call to recv fail, setti...

Java server socket buffers not being garbage collected on Mac--why?

I'm hunting a memory error in an application, and it seems to be related to the byte[] buffers generated by ServerSocketChannel.accept(). According to jvisualvm, of the 505 megs in use by the application, over 90% of the memory is being used by byte[] arrays. Tracking it further, there are 68k+ instances of byte[] and by far the most c...

Handling ungraceful shutdowns when using fork and sockets

I have a server that listens for socket connections and perform different kind of actions, depending on the request. One of them is long lived database queries, for which the server forks. The server keeps a log of all the active children and whenever asked to shutdown, it will kill all it's children before exiting. A couple of times I ...

Do I need to heartbeat to keep a TCP connection open?

I have two components that that communicate via TCP/IP. Component A acts as a server/listener and Component B is the client. The two should communicate as quickly as possible. There can only ever be one connection at any time (though that is aside to this question). A senior developer at my company has said I need to use application ...

What host to use when making a UDP socket in python?

I want ro receive some data that is sent as a UDP packet over VPN. So wrote (mostly copied) this program in python: import socket import sys HOST = ??????? PORT = 80 # SOCK_DGRAM is the socket type to use for UDP sockets sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.bind((HOST,PORT)) data,addr = sock.recv(1024) print...

How does SocketChannel know when reading a file is completed?

I am using socket channel and NIO concept to read data from client. How does Socket Channel knows when reading a file is completed? ByteBuffer byteBuffer = ByteBuffer.allocate(BUFSIZE); int nbytes = socketChannel.getChannel().read(byteBuffer); I am reading the data all at once if the data is small, but if the data is large, I read the...