Forum Navigation
SocketConduit connect close -> bad file descriptor
Moderators:
kris
Posted: 01/26/09 14:39:11I want to make a few socket requests and therefore adapted the example from the wiki as following:
private import tango.io.Console; private import tango.net.SocketConduit, tango.net.InternetAddress; void main() { // make a connection request to the server auto request = new SocketConduit; for (int i=0; i<1000; i++) { request.connect (new InternetAddress ("localhost", 8080)); request.output.write ("hello\n"); // wait for response (there is an optional timeout supported) char[64] response; size_t len = request.input.read (response); // trim the length of the response auto received = response[0..len]; // close socket request.close; // display server response Cout (received).newline; } }But I always get a bad file descriptor exception:
tango.core.Exception.SocketException?: Unable to connect socket: Bad file descriptor
I tried request.shutdown and request.detach as well, but with no luck.
Do I really need to put
auto request = new SocketConduit;within the loop?
/lars