network-programming

Why is it impossible, without attempting I/O, to detect that TCP socket was gracefully closed by peer?

As a follow up to a recent question (http://stackoverflow.com/questions/151590/java-how-do-detect-a-remote-side-socket-close), I wonder why it is impossible in Java, without attempting reading/writing on a TCP socket, to detect that the socket has been gracefully closed by the peer? This seems to be the case regardless of whether one use...

Why do SocketChannel writes always complete for the full amount even on non-blocking sockets?

Using the Sun Java VM 1.5 or 1.6 on Windows, I connect a non-blocking socket. I then fill a ByteBuffer with a message to output, and attempt to write() to the SocketChannel. I expect the write to complete only partially if the amount to be written is greater than the amount of space in the socket's TCP output buffer (this is what I exp...

How do I read strings in J2ME?

I'm using the MIDP 2.0 (JSR 118) and I just noticed that there is no reader for strings in J2ME. Does anyone know how you are supposed to read Strings from an InputStream or InputStreamReader in a platform independent way (i.e. between two java enabled cell phones of different models)? ...

java.net.URLEncoder.encode(String) is deprecated, what should I use instead?

I get the following warning when using java.net.URLEncoder.encode: warning: [deprecation] encode(java.lang.String) in java.net.URLEncoder has been deprecated What should I be using instead? ...

How do I set the socket timeout in Ruby?

How do you set the timeout for blocking operations on a Ruby socket? ...

Managing Cisco programatically; Telnet vs SNMP?

I was recently approached by a network-engineer, co-worker who would like to offload his minor network admin duties to a junior-level helpdesk tech. The specific location in need of management acts as an ISP for tenants on its single-site property, so there's a lot of small adjustments being made on a daily basis. I am thinking it wou...

How do you throttle the bandwidth of a socket connection in C?

I'm writing a client-server app using BSD sockets. It needs to run in the background, continuously transferring data, but cannot hog the bandwidth of the network interface from normal use. Depending on the speed of the interface, I need to throttle this connection to a certain max transfer rate. What is the best way to achieve this, p...

Finding an IP from an interface name

On a Linux box, the common interface names look like eth0, eth1, etc. I know how to find at least one IP using gethostbyname or similar functions, but I don't know any way to specify which named interface I want the IP of. I could use ifconfig and parse the output, but shelling out for this information seems... inelegant. Is there a w...

Proper way to write and read an xml string

I've been beating my head against this wall for quite some time now, so I thought I'd ask some experts. I need to send an xml string from one computer to the next. I would like to format the xml something like this: <xml> <author>Joe the Magnificent</author> <title>Joe Goes Home</title> </xml> Can anyone provide some assistance?...

How Is "Unix Network Programming" (two volumes)?

I've seen these books mentioned elsewhere on SO, but no detailed discussion. To better position my question... I own and frequently return to Advanced Programming in the UNIX Environment, now in it's second edition. It's a huge book, and for the material it covers, I've found it to be just great. I like the discussion of cross-platform ...

What is the optimal size of a UDP packet for maximum throughput?

I need to send packets from one host to another over a potentially lossy network. In order to minimize packet latency, I'm not considering TCP/IP. But, I wish to maximize the throughput uisng UDP. What should be the optimal size of UDP packet to use? Here are some of my considerations: The MTU size of the switches in the network is 15...

.NET Communications Component

Hi, I'm looking for a component for C#.NET 2008 Professional that is capable of doing the majority of the network communications work that is required of our application so our programmers don't have to. This component should function similarly to the way RealThinClient (RTC) does. The component must be able to gracefully lose and reg...

What are the available PHP extensions for TCP Socket Networking?

Hi, I'm looking for a PHP extension that allows me to connect, bind/listen, send, and receive data on a TCP socket. There is a PEAR package Net_Socket: http://pear.php.net/package/Net_Socket But this would require PEAR to be installed which we wouldn't want to do as this increases memory consumption. Is there an available purely C e...

What's the simplest way to call Http GET url using Delphi?

There's a web services I want to call in my application, I can use it with importing the WSDL or by just use "HTTP GET" with the URL and parameters, so I prefer the later because it's simple thing. I know I can use indy idhttp.get, to do the job, but this is very simple thing and I don't want to add complex indy code to my application. ...

Is there an optimal byte size for sending data over a network?

I assume 100 bytes is too small and can slow down larger file transfers with all of the writes, but something like 1MB seems like it may be too much. Does anyone have any suggestions for an optimal chunk of bytes per write for sending data over a network? To elaborate a bit more, I'm implementing something that sends data over a networ...

Simplest Way To Open and Use a Socket in C

I'm just starting out doing some basic network programming with C, and I found all these things about sockets and they all seem very convoluted. Maybe opening sockets with C is just convoluted itself, but I would like to know the simplest and most effective way to open and write data to a socket in the C programming language. Thanks ...

Is there a technical reason for applications to hang on DNS lookups?

If I try to quit Firefox when it's "Looking up domain.com..." it beachballs (hangs), goes into "not responding" status, then finally quits. It does this without fail. This is on Mac with the latest FF, but it's always been this way for me, even on Windows with FF and I've noticed it with other applications. Is there any technical reas...

Checking network status in C#

How do I check that I have an open network connection and can contact a specific ip address in c#? I have seen example in VB.Net but they all use the 'My' structure. Thank you. ...

Ping a site in Python?

The basic code is: from Tkinter import * import os,sys ana= Tk() def ping1(): os.system('ping') a=Button(pen) ip=("192.168.0.1") a.config(text="PING",bg="white",fg="blue") a=ping1.ip ??? a.pack() ana.mainloop() How could I ping a sites or address? ...

Parsing Binary Data in C?

Are there any libraries or guides for how to read and parse binary data in C? I am looking at some functionality that will receive TCP packets on a network socket and then parse that binary data according to a specification, turning the information into a more useable form by the code. Are there any libraries out there that do this, or...