According to MSDN you have to create a non-blocking socket like this:
unsigned nonblocking = 1;
ioctlsocket(s, FIONBIO,
and use it in the write-fdset for select() after that. To check if the connection was successful, you have to see if the socket is writeable. However, the MSDN-article does not describe how to check for errors.
How ...
I must sometimes write software to establish a socket with a particular server residing within a Cisco VPN. I simply write my software as if there were no VPN (making use of the standard sockets library). When it is time to run this program, I manually connect to the VPN using the client software installed on my computer, then run the pr...
I am fairly new to C++ programing, so I am not quite sure what I am looking for at the moment. I have experience with C#, Python (barely), and Visual Basic, but I am looking into using C++ and breaking away from .NET in general (before it completely sucks me in). My questions are as follows:
1) What would be the lightest weight, platfor...
I'm currently maintaining some web server software and I need to perform a lot of I/O operations. The read(), write(), close() and shutdown() calls, when used on a socket, may sometimes raise an ENOTCONN error. What exactly does this error mean? What are the conditions that would trigger it? I can never seem to reproduce it locally but t...
Is there any way to check if a socket has disconnected on the remote end without select() in C?
The reason I don't want to use select() is that in the case that my buffers are full, there may be data available for reading on the socket that I am intentionally ignoring and a select(readfds=[socket_fd]) would always return immediately let...
The cross platform dev environment I use has a built in function that is supposed to indicate whether or not a tcp port is available. However, the function malfunctions under Vista and always returns "available".
Is there an easy way, such as a dll function, I can use to correctly determine this information without needing .Net?
...
I have created a simple server client application using java NIO.
I used a single selector there for accepting connection, reading data and writing.
But I want an application where 1 selector will be busy in accepting the connection while the 2nd selector will read the data and the 3rd selector will write the data.
Means I donot want to...
I am writing a little Comet server in C#, and to test it I have written a little program that opens a bunch of connections, writes a little text to each of them, and then closes each of them:
int basePort = 30000;
IPAddress localAddress = new IPAddress( new byte[] { 127, 0, 0, 1 } );
List<Socket> sockets = new List<Socket>();
for( int ...
Hello,
I've been struggling with this problem for last few hours but still got no idea what's wrong. Here's the scenario:
Application built on top of the Mate framework sometimes need to exchange data with remote server over plain binary socket.
When specific packet is received I have to switch view (using ViewStack) and create custo...
Hi there,
I'm receiving from socket A and writing that to socket B on the fly (like a proxy server might). I would like to inspect and possibly modify data passing through. My question is how to handle border cases, ie where the regular expression I'm searching for would match between two successive socket A read and socket B write iter...
Hi!
i'm developing a java application using the jstun library (hxxp://jstun.javawi.de/), and i need to compare my public ip with the one chosen by the kernel (wildcard address - hxxp://java.sun.com/j2se/1.5.0/docs/api/java/net/DatagramSocket.html#DatagramSocket() ) when i create a udp socket.
what i don't understand is, if my local ip ...
Iam trying to create an iterative server based on datagram sockets (UDP).
It calls connect to the first client which it gets from the first recvfrom() call (yes I know this is no real connect).
After having served this client, I disconnect the UDP socket (calling connect with AF_UNSPEC)
Then I call recvfrom() to get the first packet fro...
Hi folks,
I would like to know if the following scenario is real?!
select() (RD) on non-blocking TCP socket says that the socket is ready
following recv() would return EWOULDBLOCK despite the call to select()
...
C#: How should TCP socket buffer data be handled? As bytes or converted to an ascii string?
I am using methods that are involved in parsing specific data from the returned tcp socket buffer, which practice would be best?
Should I process/parse my data in it's raw byte form? Or should I process it after convert it to an ascii string si...
I'm using Java DatagramSocket class to send a UDP data gram to an endpoint. The datagram must arrive at the endpoint in 60ms intervals.
I'm finding that DatagramSocket.Send can often take > 1 ms (close to 2) to package and send packets no greater than 56 bytes. This causes my packets to be delivered at 62 ms intervals, rather than 60m...
Ok so here is how things are going:
[Server] Start
[Server] Socket.AcceptConnection
[Client] Start
[Client] Socket.Connect
[Server] Receive //blocking
[Client] Send
[Server] Print
[Server] Receive
[Client] Close socket
Is there any way to know when the client as closed the connection?
I am currently using the fake packet trick as des...
When I run the following code:
struct sockaddr_in sin;
int addrlen;
addrlen=sizeof(sin);
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_addr.s_addr=inet_addr("123.456.789.112");
sin.sin_port=htons(0); // so that the kernel reserves a unique port for us
sd_server = socket(PF_INET, SOCK_STREAM, 0);
bind(...
I'm trying to pass fd between process and I found the sample code like portlisten. In the sample, a recvmsg() can take a bound socket as parameter (and leave msghdr.msg_name as NULL) but the sendmsg() cannot - it must take a sockaddr* in the msghdr.msg_name.
I tried to modify the program by connecting first but failed, and found the com...
I don't really know much about sockets except how to read and write to them as if they were files. I know a little about using socket selectors. I don't get why you have to flush a socket, what's actually happening there? The bits just hang out somewhere in memory until they get pushed off? I read some things online about sockets, but it...
I discovered a nice abstraction whereby I can read in data from UDP using a FILE. This works great for reading in data, but I cannot get it to work for spitting out data over UDP. Here is the code for reading in the UDP data over a FILE stream:
u_int8 *buf;
int sockfd = socket(AF_INET, SOCK_DGRAM, 0);
struct sockaddr_in serverAddr;
if (...