sockets

gethostbyname win32 error...

Hi all, I am using the gethostbyname() function in the usual manner... iaHost.s_addr = inet_addr(lpServerName); if (iaHost.s_addr == INADDR_NONE) { // Wasn't an IP address string, assume it is a name lpHostEntry = 0; lpHostEntry = gethostbyname(lpServerName); } to access my web site and return information. The variable, "lpServer...

How to get a specific socket and close it

I want to close a socket so I can reopen one on the same port but I do not have a handle on that socket. How can I get the socket that is listening on localhost:873 to close it? ...

Query on Select System Call

select() is defined as : int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout); nfds represents the highest file descriptor in all given sets plus one. I would like to know why is this data required for select() when the fd_set information is available. If the FDs in the set are say, 4, 8...

Are there well-known patterns for asynchronous network code in C#?

I recently wrote a quick-and-dirty proof-of-concept proxy server in C# as part of an effort to get a Java web application to communicate with a legacy VB6 application residing on another server. It's ridiculously simple: The proxy server and clients both use the same message format; in the code I use a ProxyMessage class to represent bo...

socket trouble in python

I have a server that's written in C, and I want to write a client in python. The python client will send a string "send some_file" when it wants to send a file, followed by the file's contents, and the string "end some_file". Here is my client code : file = sys.argv[1] host = sys.argv[2] port = int(sys.argv[3]) sock = socket.socket(soc...

Socket ReadFile Issue

We have a application which uses ReadFile to read a socket . In one of the scenarios the ReadFile gets a call saying that there are 2 bytes to read , but when the ReadFile tries to read this it return with bytesread as 0 . Does this mean that the socket on the other end has closed down ? . I mean does it necessarily mean that the socket ...

What does 'end of stream' mean when working with sockets

When working with Sockets in Java, how can you tell whether the client has finished sending all (binary) data, before you could start processing them. Consider for example: istream = new BufferedInputStream (socket.getInputStream()); ostream = new BufferedOutputStream(socket.getOutputStream()); byte[] buffer = new byte[BUFFER_SIZE]; i...

Configuring sockets to use small packets in Java

I am processing time critical messages which are routed to me via a very slow network connection. I am connecting to the originating server (which I have no control over) with a Java TCP/IP Socket. The data is of varying length but is usually around 5000bytes and so ends up getting broken into multiple packets of roughly 1400 bytes. ...

Structs to Byte Arrays to send over sockets

What is the best way to get a byte array from a struct to send over TCP sockets? I'm using .Net (VB or C#). ...

Spoofing Java UDP Packets

I am looking to spoof UDP packets using Java. Are there any good Java libraries out there that allow you to create your own RAW SOCKETS? Sorry, forgot the Java stuff. ...

How many socket connections possible?

Has anyone an idea how many tcp-socket connections are possible on a modern standard root server? (There is in general less traffic on each connection, but all the connections have to be up all the time.) EDIT: We will use a Linux Server. ...

Correct way to close a socket and ObjectOutputStream? [Java]

Hi all, I am writing a networked application in Java, to communicate between the Client and the Server I am using Serialized objects to represent data/commands and sending them through object output/input streams. I am having problems cleanly closing the Connections, I assume that I am missing something fundamental that I do not really...

how read all the server's responses from a socket?

hello, i have a very big problem... i'm working with sockets in C. i ask a question to the server which sends me many answers. the problem is that the client receive the first response and the the connection is closed. what can i do? i tried with setsockopt()... SO_KEEPALIVE or SO_LINGER but i haven't resolved the problem. Can you help ...

Call recv() on the same blocking socket from two threads

What happens if I have one socket, s, there is no data currently available on it, it is a blocking socket, and I call recv on it from two threads at once? Will one of the threads get the data? Will both get it? Will the 2nd call to recv return with an error? ...

Binding to a socket in Tomcat

I am writing a Tomcat app. As part of its functionality, it needs to send out a UDP multicast when certain events happen. Right now my code goes something like this (host and group are fake, exception handling ripped out to save space): import java.net.*; /* ..... */ DatagramSocket socket = new DatagramSocket(12345); InetAddress group...

socket behaviour when in blocking mode

I'm interested in the behavior of send function when using a blocking socket. The manual specifies nothing about this case explicitly. From my tests (and documentation) it results that when using send on a blocking socket I have 2 cases: all the data is sent an error is returned and nothing is sent In lines of code (in C for exampl...

Is it possible to do secure sockets (not https) with silverlight 2/3 ?

I need to do push feed to clients (not through polling), to silverlight clients fast and securely, is it possible to do secure sockets with silverlight ? ...

How to prevent application freeze if server unavailable?

InetAddress serverAddr = InetAddress.getByName(serverAddress); String hostname = serverAddr.getCanonicalHostName(); Socket socket = new Socket(serverAddr, portNumber); // Freezes before this line if the server is unavailable socket.setSoTimeout(3000); Does anyone know how to implement the check of server availability or prevent the fre...

Sockets Authentication is failing using NegotiateStream

I've got a Socket that is connected that I use to get HTTP header responses. If I skip authentication, everything works fine (unless the page requires authentication). But when I step into this code, it always throws an IOException on the AuthenticateAsClient line. The message is: of "Unable to read data from the transport connection:...

How do I send and receive an integer array from client to server in Java socket programming?

I'm having a problem sending a job (an integer array) from client to server in two different packages over a socket connection. Any ideas please? I can explain further if my question is not clear enough. ...