sockets

C# begin*() method vs threadpool for a server

For making a scalable multiuser server in C#, which of these two types of servers are more efficient? You can see an example of the async server using the begin* methods (like beginaccept, beginsend) here, and the threadpool implementation here. I know what a threadpool is and how it works so I pretty much understand how that implement...

Querying full DNS record

I do alot of programming in *nix using C gcc. I know how to do a basic gethostbyname(). BUt what if I wanted to pull down the entire DNS record. More to the point, is there a function that I'm missing that allows you to specify the specific record that you want to pull? Or will I need to do this manually through a UDP socket? ...

C# Raw Sockets Port Forwarding

I am trying to create a simple C# app which does port forwarding, and need to know how to use the IP_HDRINCL socket option to try to fake out the receiving end to think the connection is really to the source. Any examples would be greatly appreciated. ...

Windows tool for sending complete http body ( including headers ) to server

I was wondering if anyone knew of a tool where I could send a fully formed HTTP body ( headers & content ) to a web server. So far the best I've got is putty but was hoping for something where I could look @ and edit the payload then click a button and send it. ( I could probably write something like this in a couple minutes but was ho...

Asynchronous TCP Communication in .NET

Quick question here: is there any obvious benefit to use asynchronous communication with the NetworkStream class (generated by TcpClient), i.e. the BeginRead/BeginWrite methods rather than running a separate thread and using synchronous operations on that, i.e. Read/Write? My impression has been (it could easily be quite wrong) that the ...

Problem transmitting null character over sockets

I am writing a small Java server, and a matching client in C++, which implement a simple IM service over the STOMP protocol. The protocol specifies that every frame (message that passes between server and client, if you will) must end with a null character, which in code I refer to as '\0', both in Java and in C++. However, when I tran...

Why doesn't Ruby's select return the socket?

I'm trying to use select on STDIN and a TCP socket in Ruby, but for some reason, the value returned from select never seems to match one of the choices; it looks like it's the socket that's being returned, but it doesn't match using == (or equal?). Can anyone tell me why the result returned from select doesn't match the objects I passed ...

Is there a standard command-line tool for unix for piping to a socket?

I have some applications, and standard Unix tools sending their output to named-pipes in Solaris, however named pipes can only be read from the local storage (on Solaris), so I can't access them from over the network or place the pipes on an NFS storage for networked access to their output. Which got me wondering if there was an analogo...

socket programming in client

I wrote this program in C++ and on Linux platform. I wrote a client and server socket program. In that client program, I wrote socket function and immediately after that I am doing some other actions not at all depending on socket (I wrote 2 for loops for some other logic). After that I prepared the structures required for the socket ...

How to keep process from exiting when a pthread exits?

I am writing a server program in C wherein every time a client connects, I create a new pthread to handle the client's requests. When all of the threads exit, however, then my program exits, as though a call to exit() has been made. This is a problem - how can I overcome it? Lets say the server is running, and 2 clients connect. Once t...

One big byte buffer or several small ones?

I'm learning C# asynchronous socket programming, and I've learned that it's a good idea to reuse byte buffers in some sort of pool, and then just check one out as needed when receiving data from a socket. However, I have seen two different methods of doing a byte array pool: one used a simple queue system, and just added/removed them f...

C# Begin/EndReceive - how do I read large data?

When reading data in chunks of say, 1024, how do I continue to read from a socket that receives a message bigger than 1024 bytes until there is no data left? Should I just use BeginReceive to read a packet's length prefix only, and then once that is retrieved, use Receive() (in the async thread) to read the rest of the packet? Or is ther...

c#/.Net Socket.Shutdown..

I recognize this type of question has a long history, but the way I am using this must be the correct '.net way' and yet it does not seem to work. I have a trivial synchronous IP server daemon that does a simple AcceptSocket, do some stuff, socket.send, socket.shutdown, socket.close. My client is another trivial C# app that does URLDo...

Is there a beginner's book for C++ socket programming?

I'm fairly new to C++ sockets. Is there a book for beginners for C++ socket programming? for windows i really need help ive been through alot of tutorials dont get any of it and im using dev-C++ ...

How can a web page communicate with a local rich client application

Hi, I need to implement a process where users punch in a few details into a web page, and have this information fired as some sort of an event to a Java rich client application (SWING) on the same host. One idea was perhaps implementing an applet that would initiate socket communication with a listener implemented by the SWING applicat...

Count the number of packets sent to a server from a client?

So I'm almost done an assignment involving Win32 programming and sockets, but I have to generate and analyze some statistics about the transfers. The only part I'm having trouble with is how to figure out the number of packets that were sent to the server from the client. The data sent can be variable-length, so I can't just divide the ...

How to detect when a Protocol Buffer message is fully received?

This is kind of a branch off of my other question. Read it if you like, but it's not necessary. Basically, I realized that in order to effectively use C#'s BeginReceive() on large messages, I need to either (a) read the packet length first, then read exactly that many bytes or (b) use an end-of-packet delimiter. My question is, are eith...

What's the difference between TIME-WAIT Assassination and SO_REUSEADDR

I was reading about using the SO_LINGER socket option to intentionally 'assassinate' the time-wait state by setting the linger time to zero. The author of the book then goes on to say we should never do this and in general that we should never interfere with the time-wait state. He then immediately recommends using the SO_REUSEADDR opt...

socket programming: How do I handle out of band data

I just looked into wikipedia's entry on out-of-band data and as far as I understand, OOB data is somehow flagged more important and treated as ordinary data, but transmitted in a seperate stream, which profoundly confuses me. The actual question would be (besides "Could someone explain what OOB data is?"): I'm writing a unix applicatio...

Java TCP Socket Sniffing

I am using TCP sockets to communicate data between a server and client program using a specific port number on the same computer (localhost). I need a software that can capture the data being sent/received through that socket? (or) What's the simplest way of sniffing packets from a specified port in Java? ...