sockets

Problem with Closing Sockets. Program Halts.

I am having some trouble with this code. The problem is when i Request the Server to send me some data and the client just Disconnects when the server tries to send me data, the application Exists. Here's the lines I think cause the problem int SendBinary(int *byte, int length) { int bytes_sent; bytes_sent = send(connecting_so...

.NET - How can I get more information for an error in my program? Error: "The thread 0x566967f6 has exited with code 0 (0x0)"

Maybe you can help me... I am writing a program in Windows Mobile that connects to a mail-server and retrieves data from a POP3-server. I am using a third-party (free) socket available from here. I am using VS 2008 (in VB.NET) and the device-emulators. I can connect without any problems and execute my various commands (such as logging ...

Why am I seeing 'connection reset by peer' error?

I am testing cogen on a Mac OS X 10.5 box using python 2.6.1. I have a simple echo server and client-pumper that creates 10,000 client connections as a test. 1000, 5000, etc. all work splendidly. However at around 10,000 connections, the server starts dropping random clients - the clients see 'connection reset by peer'. Is there some...

Android HTTP Connection

Can anybody tell my why this doesn't work in the Android emulator? From the browser I have access and the server is internal. All I can think of is that I'm missing some configuration on my app so it can access the network layer. try { InetAddress server = Inet4Address.getByName("thehost"); //Doesn't work either //or InetAdd...

Does unblocking connect to socket cause a context switch?

I'm using winsock and calling connect on a non-blocking socket. I occasionally see some delay (up to 200ms) before the function returns when the CPU is hogged by other processes. From what I know, a connect on a non-blocking socket should return immediately, but perhaps connect causes a context switch and since the CPU is working hard it...

My simple poll() example only partially works

I have included the code below. The program is supposed to accept telnet connections on port 8888 and then send and messages from each telnet client using poll and send and recv but It doesn't quite work 100%. It seems certain connections can always send messages to anyone and the program works fine but there is always at least one clien...

How should I close a socket in a signal handler?

I'm writing a very simple server that loops forever until Ctrl-C is pressed. I'd like to have the signal handler for ctrl-c close the open sockets and shut down the server, but I don't know what the scope is for a signal handler, and I don't like the idea of declaring the socket(s) I would need to close to be global. Can someone offer s...

Proper way to stop listening on a Socket

I have a server that listens for a connection on a socket: public class Server { private Socket _serverSocket; public Server() { _serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _serverSocket.Bind(new IPEndPoint(IPAddress.Any, 1234)); _serverSocket.Listen(1); } public void Start()...

What's the best way to monitor a socket for new data and then process that data?

Please pardon my C#.Net newbie status. If this is obvious and I missed it from the docs, a link to the relevant page or sample code would be appreciated. I am working on an application that will accept a TCP socket connection from a Java application. (Yes, Java is required on that part. It's a Sun SPOT device and Java is the only option...

How do I set the time out of a socket.connect() call?

I have an app that connects to a host that might be down. If the host is down I don't want to wait for the 30 or so seconds it takes to time out. I'm using blocking sockets at the moment. I've been looking at socket.poll() and socket.select() but I'd rather just have a time setting on the socket. I don't mind if it's a setting I have to...

select on UDP socket doesn't end when socket is closed - what am I doing wrong?

I'm working on Linux system (Ubuntu 7.04 server with a 2.6.20 kernel). I've got a program that has a thread (thread1) waiting on a select for a UDP socket to become readable. I'm using the select (with my socket as the single readfd and the single exceptfd) instead of just calling recvfrom because I want a timeout. From another threa...

Python/Twisted - Sending to a specific socket object?

I have a "manager" process on a node, and several worker processes. The manager is the actual server who holds all of the connections to the clients. The manager accepts all incoming packets and puts them into a queue, and then the worker processes pull the packets out of the queue, process them, and generate a result. They send the resu...

How to resolve a Stream Closed Error in java?

Hello, I am really thankful for everyone who would read this and try to help me, the following is the code I am trying to write for a server class for a socket-programming project for college: import java.io.*; import java.net.*; import java.io.File; class Server{ public static void main (String[]args)throws IOException{ Serve...

What is the best way to pass information from java to c++?

I have a java application I need to pass some info to a C++ program. It has been suggested that I use some simple socket programming to do this. Is this the best way? If not what are the alternatives? If so, how should I go about learning about socket programming? ...

Socket programming in C.

Ok, so I'm trying to get some UDP code working and I'm barely green when it comes to network programming using C. I'm using the sample file from here Basically I'm just listening for incoming UDP packets on a given port and then I want to send some data back the same way. Below is the relevant part. At this point the socket is set up a...

Java sockets

I have implemented some remote method invocation using sockets opened on 127.0.0.1. During programs run, computers public IP address changes, because my program connects to net via GPRS modem from time to time. Can you tell me how does that affect my opened sockets? Java version is 1.3, windows platform. There are several network interf...

Can the server use the same socket to send the response to the client? how?

I am using Berkeley sockets (both: Internet domain and Unix domain) and I was wondering if the server can use the same sockets for reading the request and writing a response to the client. Or should the client create an other socket to wait for the replay and the server connect to it after processing the message received. By the way, I ...

What happens to not accepted connection?

Assume a listening socket on localhost:80 and a client connecting using: telnet localhost 80 The problem is that I want only to accept a limited number of concurrent clients, assume only one. After that I simply don't accept any. The problem that I saw using: netstat -a is that next client connection was established. Yes I don't proce...

Streaming files over the network with random access - java

Hey all, So ive got a need to play music files from a server on the network, in a java client app. I was thinking Sockets - have the server open a music file as a stream, and have the client connect to that and read & play it as an InputStream. Which would work - except AFAICS users wont be able to seek into the file(which they can curr...

Java Socket Programming

I am building a simple client/server application using java sockets and experimenting with the ObjectOutputStream etc. I have been following the tutorial at this url http://java.sun.com/developer/technicalArticles/ALT/sockets starting half way down when it talks about transporting objects over sockets. See my code for the client http:/...