sockets

Can I close and reopen a socket?

I learned an example of usage of sockets. In this example a client sends a request to a server to open a socket and then the server (listening to a specific port) opens a socket and everything is fine, socket is "opened" from both sides (client and server). But it is still not clear to me how flexible is this stuff. For example, is it p...

Can I avoid a threaded UDP socket in Python dropping data?

...

Find a free port C#

Hi, I'm writing a ftp server library (because I need it and I can't find any good solutions for this) in C# and I have two questions: How does IPEndPoint finds a free port when I do new IPEndPoint(IPAddress.Any, 0), for example? Is it possible to find a free port from a range (for example from 1023 to 65535), without the GetActiveTcpC...

.NET TCP socket with session

Is there any way of dealing with sessions with sockets in C#? Example of my problem: I have a server with a socket listening on port 5672. TcpListener socket = new TcpListener(localAddr, 5672); socket.Start(); Console.Write("Waiting for a connection... "); // Perform a blocking call to accept requests. TcpClient client = soc...

Multiple INET sockets (mulple IP's too) connected to UNIX sockets

HOST = same host all the time, accepts multiple connection. I have a dedicated server and I will buy extra IP's. Socket 1 connects to HOST:PORT, from IP-1 Socket 2 connects to HOST:PORT, from IP-1 Socket 3 connects to HOST:PORT, from IP-1 Socket 4 connects to HOST:PORT, from IP-2 Socket 5 connects to HOST:PORT, from IP-2 Socket 6 connec...

can I make a UDP b-socket hold only a single message ?

can I make a UDP berkley socket hold only a UDP single message ? meaning it will override existing message if unread message is present when a new message arrives ? ...

Does Socket open another thread? Does it return something?

In the client application I call new Socket(serverIP,serverPort). As a result the client application sends a request to the server application to open a socket. Does it start a new thread? I mean which of the following is true? Client application sends a request and immediately starts to execute following commands (not waiting for the ...

problem with closing sockets

Hi, I'm trying to write a client/server program with threads. I close the socket once the connexion is finished. The servers gets plenty of new connexions, and the socket number (file descriptor) increases very quickly: after 5 minutes running I was already at around file descriptor number 800! Is this a normal thing? Do threads share...

What's the difference between using ProtocolType.IP and ProtocolType.Tcp

I've just answered problem with sockets in c# where in my example code I initializing my socket using ProtocolType.IP as this is what I've always used in my own code, and it has never caused me problems. But I see many examples specifying ProtocolType.Tcp. I guess, what I'm asking is, by using ProtocolType.IP instead of ProtocolType.Tc...

How can I force the server socket to re-accept a request from a client?

For those who do not want to read a long question here is a short version: A server has an opened socket for a client. The server gets a request to open a socket from the same client-IP and client-port. I want to fore the server not to refuse such a request but to close the old socket and open a new one. How can I do ti? And here is...

Why do sockets not die when server dies? Why does a socket die when server is alive?

I try to play with sockets a bit. For that I wrote very simple "client" and "server" applications. Client: import java.net.*; public class client { public static void main(String[] args) throws Exception { InetAddress localhost = InetAddress.getLocalHost(); System.out.println("before"); Socket clientSideSocket = null;...

Python: Matching & Stripping port number from socket data

Hello, I have data coming in to a python server via a socket. Within this data is the string '<port>80</port>' or which ever port is being used. I wish to extract the port number into a variable. The data coming in is not XML, I just used the tag approach to identifying data for future XML use if needed. I do not wish to use an XML pyt...

Problem reading hexadecimal buffer from C socket

I'm using the SDL_net sockets API to create a server and client. I can easily read a string buffer, but when I try to send hexadecimal data, recv gets the length, but I cannot seem to be a able to read the buffer contents. IPaddress ip; TCPsocket server,client; int bufSize = 1024; char message[bufSize]; int len; server = SDLNet_TCP_Ope...

Java socketserver: How to handle many incoming connections?

I am writing a simple multithreaded socketserver and I am wondering how best to handle incoming connections: create a new thread for each new connection. The number of concurrent threads would be limited and waiting connections limited by specifying a backlog add all incoming connections into a queue and have a pool of worker threads...

What is the difference between a socket and a port connection in MySQL?

Hi guys, when I am using 'localhost' as the host for MySQL database, sequel pro alert me that I will be using socket. On the other hand, if I use '127.0.0.1', i would be using the ip address and port 3306 to reach the server. What is the difference? ...

When should I send QUIT to SMTP server? and how long should I keep a session?

I am programming a smtp sender to send large number of distinct emails (not spam). As there are many destination addresses which are from common provider like hotmail.com/gmail.com. I would like to pool the TCP connections in order to reuse the session. Is this a good practise? Or should I disconnect and connect to send distinct mails in...

Encrypting socket communication with RSA in C#

I'm currently trying to implement a socket server that enables the clients to send some commands to start and stop various services that the server provides. I got the communication between client and server running, and got the server to respond to the commands the clients send. The next step would be to encrypt the communication betwee...

How to solve a deallocated connection in iPhone SDK 3.1.3? - Streams - CFSockets

Hi everyone, Debugging my implementation I found a memory leak issue. I know where is the issue, I tried to solve it but sadly without success. I will try to explain you, maybe someone of you can help with this. First I have two classes involved in the issue, the publish class (where publishing the service and socket configuration is ...

Fast way to test if a port is in use using Python

I have a python server that listens on a couple sockets. At startup, I try to connect to these sockets before listening, so I can be sure that nothing else is already using that port. This adds about three seconds to my server's startup (which is about .54 seconds without the test) and I'd like to trim it down. Since I'm only testing loc...

How to write byte by byte to socket in PHP?

How to write byte by byte to socket in PHP? For example how can I do something like: socket_write($socket,$msg.14.56.255.11.7.89.152,strlen($msg)+7); The pseudo code concatenated digits are actually bytes in dec. Hope you understand me. ...