sockets

How to duplicate socket for target process under different user

I've hit upon a problem with WSADuplicateSocket, which I'm using to duplicate a socket for use by a different process. It works find when both processes are running under the same Windows user, but fails with error code 10022 (WSAEINVAL) when they are running under different users. Specifically, the process calling WSADuplicateSocket is...

Proper way to stop TcpListener

I am currently using TcpListener to address incoming connections, each of which are given a thread for handling the communication and then shutdown that single connection. Code looks as follows: TcpListener listener = new TcpListener(IPAddress.Any, Port); System.Console.WriteLine("Server Initialized, listening for incoming connections")...

php fsockopen

I have a simple php script on a server that's using fsockopen to connect to a server. <?php $fp = fsockopen("smtp.gmail.com", 25, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { echo fgets($fp, 1024); fclose($fp); } ?> The problem is the the script times out and fails to connect. If i change the...

What is the state of a TCP socket after remote closed?

Hello, Say I have accepted() a connection to my server (that runs on a Solaris) and the client has closed the connection. What is the state of the socket (in netstat categories) of the socket on the server side before I close() it on the server side? Is it BOUND? ...

SSL Socket in Windows. Library? Synchronous/Asynchronous? Threads?

Hello I have a 2 threads application. One GUI thread and one worker thread (CWinThread) in which I make time consuming operations - calculations and HTTP comunication. I have to switch from HTTP to SSL socket connection. I also need to make a verification of server certificate (is it trusted, is it expired, is it revoked) Which libr...

Why can't Nginx POST to my Perl backend?

EDIT: So I just found out that GET methods indeed work, but POST methods however do not work! That might be significant. So I am on Debian Etch, running Nginx. Nginx does not normally serve cgi/pl files so I have followed a guide to get my backend working. http://technotes.1000lines.net/?p=23 My backend works fine on Apache but I had ...

Why shouldn't I run my non-web server software on port 80?

Considering there are so many draconian firewalls in the world, is there any reason I shouldn't run server software on port 80 to guarantee greatest possible accessibility? It seems that the most common firewall exception is to allow outbound connections on port 80. I understand that any sort of packet inspection would still block my non...

In Ruby, how does one get their IP octet without going through DNS?

I can, on some of my systems, get my IP address (192.68.m.n format) by doing this: addr = IPSocket::getAddress(Socket.gethostname()) ...the trouble is that this only works if the name the local machine uses for itself is the name the DNS server associates with it. How *&#( hard can it be for ruby to just return its primary interface'...

How to write a socket based Custom Transport for WCF

I have a mobile platform that I am trying to write some communications code on. The platform provides a proprietary communication mechanism that is based on standard socket functions. Basically, the platform's socket API looks exactly the same as the standard Windows Socket API, except with a prefix on each of the functions. I would l...

104, 'Connection reset by peer' socket error, or When does closing a socket result in a RST rather than FIN?

We're developing a Python web service and a client web site in parallel. When we make an HTTP request from the client to the service, one call consistently raises a socket.error in socket.py, in read: (104, 'Connection reset by peer') When I listen in with wireshark, the "good" and "bad" responses look very similar: Because of the s...

How to signal select() to return immediately?

I have a worker thread that is listening to a TCP socket for incoming traffic, and buffering the received data for the main thread to access (let's call this socket A). However, the worker thread also has to do some regular operations (say, once per second), even if there is no data coming in. Therefore, I use select() with a timeout, so...

Are Sockets the best way to go ?

I'm working on a tool which would need to communitacte: send and recieve files with other remote instances of the tool over the internet. Which communication option would be best to use in this case ? Sockets? ...

PHP: How to set a timeout on socket_read?

I was wondering how can I set a timeout on a socket_read call? The first time it calls socket_read, it waits till data is sent, and if no data is sent within 5 secs I want to shutdown the connection. Any Help? I already tried "SO_RCVTIMEO" with no luck. Im creating a socket with socket_create() and listening on it for connections, then ...

Socket with recv-timeout: What is wrong with this code?

I'm trying to implement a socket with a recv timeout of 1 Second: int sockfd; struct sockaddr_in self; struct sockaddr_in client_addr; int addrlen=sizeof(client_addr); ssize_t nBytes; sockfd = socket(AF_INET, SOCK_STREAM, 0); self.sin_family = AF_INET; self.sin_port = htons(PORT); self.sin_addr.s_addr = INADDR_ANY; int on = 1; setso...

How do I send an ARP packet through python on windows without needing winpcap?

Is there any way to send ARP packet on Windows without the use of another library such as winpcap? I have heard that Windows XP SP2 blocks raw ethernet sockets, but I have also heard that raw sockets are only blocked for administrators. Any clarification here? ...

Mixing File Handles and Sockets in Winsock

I'm porting some code from BSD sockets to Winsock, and I'm not sure how to handle the case below. My original application runs a select on both stdin and the network socket: FD_SET(sock, &fd); FD_SET(0, &fd); ... if (select(..., &fd, ... )...) Trying to run this in Winsock gives an error 10038 (WSAENOTSOCK), which makes sense, since ...

What the cost of WSAStartup and WSACleanup?

I have a c++ win32 program that uses sockets to download some data from a server. Before using sockets on Windows, WSAStartup must be called. MSDN says: "There must be a call to WSACleanup for each successful call to WSAStartup. Only the final WSACleanup function call performs the actual cleanup." The easiest way for me is to call WSAS...

Delphi: Limiting TCP connections

Hello. I'm using the TServerSocket component in my Delphi application. I would like to limit client connections, let's say to one thousand. Unfortunately i don't know how to do that. The component does not provide any properties like 'MaxConnections' or any other like this one. I create new server threads (TServerClientThread) using th...

Running a Socket Server in Cocoa

I'm trying to write a program that uses sockets to connect with other instances of itself over the network. Since eventually I'd like to write a Windows version as well, I'm currently using BSD sockets on the OS X side so that I can ensure that it will be compatible with the (eventual) Windows version. The only way that I've been able t...

socket.shutdown vs socket.close

I recently saw a bit of code that looked like this (with sock being a socket object of course): sock.shutdown(socket.SHUT_RDWR) sock.close() What exactly is the purpose of calling shutdown on the socket and then closing it? If it makes a difference, this socket is being used for non-blocking IO. ...