sockets

WebDAV with J2ME

Is there a way to use WebDAV with J2ME (some libraries or manual coding)? I've tried: - javax.microedition.io.HttpConnection, but "SEARCH" method not supported there - javax.microedition.io.SocketConnection with Http request - nothing returns in response Maybe something wrong with my code or HTTP header: String response = ""; Strin...

Applying a regular expression to a Java I/O Stream

I seek an example of applying a regular expression to a Java I/O stream that doesn't simply convert the stream to a string as I would like to preserve binary data. Most of the examples on the Internet focus on text data... ...

How to get the next hub

I want to write a Java program in which, if I give destination IP address, I will get the information on next hub to reach that IP. So how can I achieve this? Thanks Bapi ...

Detect whether a socket program is connecting to itself

How, in C, can I detect whether a program is connecting to itself. For example, I've set up a listener on port 1234, then I set up another socket to connect to an arbitrary address on port 1234. I want to detect whether I'm connecting to my own program. Is there any way? Thanks, Dave ...

Boost, sending files over the network using tcp, prefered method ?

In the boost examples in the documentation, tcp:iostream is used to very simply send streams over the network. In other examples write() is used to write data to the socket instead with a bit more code involved. What is the difference between those 2 methods? Pros and cons? Is there something else that should be used instead ? ...

CAsyncSocket and threading

I'm using a MFC CAsyncSocket to do some network communication in a multi-threaded environment. After several hours of trying to get the accepted sockets to accept incoming data I came across a page that states that for a CAsyncSocket's OnReceive function to be called the socket has to be in the context of the main GUI thread. Moving it...

Instantly detect client disconnection from server socket.

How can I detect that a client has disconnected from my server? I have the following code in my AcceptCallBack method static Socket handler = null; public static void AcceptCallback(IAsyncResult ar) { //Accept incoming connection Socket listener = (Socket)ar.AsyncState; handler = listener.EndAccept(ar); } I need to find a way t...

Why doesn't the handle_read method get called with asyncore?

I am trying to proto-type send/recv via a packet socket using the asyncore dispatcher (code below). Although my handle_write method gets called promptly, the handle_read method doesn't seem to get invoked. The loop() does call the readable method every so often, but I am not able to receive anything. I know there are packets received on ...

SSL socket php code needs to be converted to Java

I have a Pem file that I use with this php code to connect to a c++ SSL server, but now I need this php code written in Java $ctx = stream_context_create(); stream_context_set_option($ctx, 'ssl', 'local_cert', 'cert.pem'); stream_context_set_option($ctx, 'ssl', 'passphrase', $pass); $fp = stream_socket_client('ssl://serverURL', $err,...

TCP Socket.Connect is generating false positives

I'm experiencing really weird behavior with the Socket.Connect method in C#. I am attempting a TCP Socket.Connect to a valid IP but closed port and the method is continuing as if I have successfully connected. When I packet sniffed what was going on I saw that the app was receiving RST packets from the remote machine. Yet from the traci...

Flash and PHP, live user environment: how do I use sockets?

I've been scouring Google to find out how I can make Flash bring at least two users together in an environment. What I've been trying to do is, for example: both users load http://example.com/myflashenvironment.html, and on that page is the same flashenv.swf file that they both see from two different computers. In the flashenv.swf there ...

Server and Client using Sockets

Are there any examples of a server and a client that use sockets, but that have send and get methods? I'm doing this networked battleship program, almost finished, but can't get the server and clients to work. I have made a chat program that only sends strings, but this time I need to send objects. I'm already frustrated, so is there ...

PHP webserver connect to C# program on same server -- What am I looking for?

So I have a webserver in which user can remotely control an external electronic board which due to certain conditions force me to put a desktop program using C# as the middle-man. What is the magic keyword I'm looking for? At first I thought of socket but every socket searches involve server-client over TCP... it's the same machine so t...

poll() in Ruby?

I am currently porting a self-written network application from C++ to Ruby. This network application often needs to manage around 10.000 sockets at the same time, that means it needs quick access to any sockets that have readable data available, incoming connections, etc. I have already experienced while writing it in C++, that select()...

PHP: socket listen problem

Here is my code: <?php $host = "127.0.0.1"; $portListen = 1234; $portSend = 1240; // create socket $sSender = socket_create(AF_INET, SOCK_STREAM, 0); socket_connect($sSender, $host, $portListen); socket_write($sSender, "test", strlen ("test")); $sListen = socket_create(AF_INET, SOCK_STREAM, 0); socket_set_option($sListen, SOL_SOC...

TCP async sockets throwing 10057

I've written the following code: public static void BeginListen( int port ) { IPAddress address = IPAddress.Any; IPEndPoint endPoint = new IPEndPoint( address, port ); m_Socket = new Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp ); m_Socket.Bind( endPoint ); m_S...

Blocking socket returns EAGAIN

One of my projects on Linux uses blocking sockets. Things happen very serially so non-blocking would just make things more complicated. Anyway, I am finding that often a recv call is returning -1 with errno set to EAGAIN. The man page only really mentions this happening for non-blocking sockets, which makes sense. With non-blocking, the...

Iterating a read() from a socket

Is this the proper way to iterate over a read on a socket? I am having a hard time getting this to work properly. data.size is an unsigned int that is populated from the socket as well. It is correct. data.data is an unsigned char *. if ( data.size > 0 ) { data.data = (unsigned char*)malloc(data.size); memset(&data.data, 0, data...

java.net.ConnectException: Connection timed out: connect exception occur

Hi, I have this code, can you help me to solve this problem? I have written this code: out = new DataOutputStream(urlConnection.getOutputStream());//exception occur String content = (String) remoteUrlList.get(urlID + ".params"); content = (content == null ? "" : content + "&") + "content=" + URLEncoder.encode(textArea.getText()); if...

Java Socket close not detected

I am writing a quick server to test an application. If i close the socket on the other end it does not throw and exceptions that the socket is closed. I keeps writing 100mb of random data( what it is suppose to do). How can i detect if the other end closed connection? import java.io.PrintWriter; import java.io.BufferedReader; import jav...