sockets

Buffered socket reading

Hi guys, I have a problem - I don't know the amount of data being sent to my UDP server. The current code is this - testing in irb: require 'sockets' sock = UDPSocket.new sock.bind('0.0.0.0',41588) sock.read # Returns nothing sock.recvfrom(1024) # Requires length of data to be read - I don't know this I could set recvfrom to 65535 ...

Sending a two byte sequence from an iphone application to a WLAN module in adhoc mode

Hi programmers, does anybody of you know some code snippets on opening an CFSOCKET and sending a two byte sequence via TCP/IP to a WLAN module, which is programmed to serialnet, listening on PORT 5100, the IP-address of the modul is: 192.168.100.1. I try to get those two bytes out of a UART of the WLAN module. I have bought "pTerm" and...

.NET 2.0: An established connection was aborted by the software in your host machine

Scenario: I try to post a video to YouTube with the following code: YouTubeEntry createdEntry = service.Upload(newEntry); This works fine on my developer machine (running Windows XP). It fails on a Win2k server (running .NET 2.0) with the following error: 2010-07-15||01:14:08 PM||An established connection was aborted by the software...

Partial uploads, upload only header.

Is there a way in PHP use a HTML form to upload only the header of the file. The length of the header is defined within the first few bytes of the file, I want only that part nothing else. After I have received the last byte of the header, I don't want any more of the file. Is there a graceful way to do this in PHP or am I going to have ...

Help about ActionScript socket communication with .Net

I'm using ActionScript to connect to a C# socket server. In the client (ActionScript), I use the following to send data: var socket:Socket = new Socket("localhost", 8080); socket.writeUTF("hello"); socket.flush(); In the server (C# 4.0), I use this: server = new TcpListener(IPAddress.Any, 8080); server.Start(); TcpClient client = ser...

socket.getaddrinfo fails on one machine; works on another apparently-identical one. Why?

I've got a laptop and a desktop, both running Ubuntu 10.04, both running the stock Python 2.6.5 that comes with Ubuntu. On the laptop, the following program #!/usr/bin/env python import socket print(socket.getaddrinfo("localhost", 8025, 0, socket.SOCK_STREAM)) works -- i.e., it prints out some stuff without getting an error. The stu...

c++ - How to serialize an object to send over network

I'm trying to serialize objects to send over network through a socket using only STL. I'm not finding a way to keep objects' structure to be deserialized in the other host. I tried converting to string, to char* and I've spent a long time search tutorial, posts in internet and until now I found nothing. Is there a way to do it only with...

Simple multithreaded server in C++?

I want to write a simple server application that will take commands from a client application and run those commands in separate threads. I was looking at the server class in dlib. Does anyone have experience using this? How does it compare to using Boost's Asio? Example of server in dlib Examples of client/server in Boost Asio ...

SO_REUSEPORT on linux

Hi I want to know if SO_REUSEPORT option is enabled in LINUX 2.6 or not ?? If I try to use it and compile my code I get following error 01.c:72: error: `SO_REUSEPORT' undeclared (first use in this function) 01.c:72: error: (Each undeclared identifier is reported only once 01.c:72: error: for each function it appears in.) Using the a...

stream_socket_server: Client browser randomly aborting?

Below is partial code to an experimental http server app I'm building from scratch from a PHP CLI script (Why? Because I have too much time on my hands). The example below more closely matches PHP's manual page on this function. The problem I'm getting is when connecting to this server app via a browser (Firefox or IE8 from two separat...

Negotiating TLS with ESMTP over sockets

I have a simple SMTP client, to which I am attempting to add TLS support. I am unsure as to what occurs after the client issues the 'STARTTLS' command. Most sources (including the RFC itself) describe it as the negotiation of a TLS session, but this is not particularly clear. How does one go about doing this? My client is written in ...

WSASYSCALLFAILURE with overlapped IO on Windows XP

I hit a bug in my code which uses WSARecv and WSAGetOverlapped result on an overlapped socket. Under heavy load, WSAGetOverlapped returns with WSASYSCALLFAILURE ('A system call that should never fail has failed') and my TCP stream is out of sync afterwards, causing mayhem in the upper levels of my program. So far I have not been able to...

reading in C++ a socket open by Java + structure alignment

Hi All I am trying to write in Linnux a client in C++ using boost::asio data from a socket. The server is built in Java. The issue I have now is that I cannot read correctly some piece of information from the socket. If the client is done in JAVA everything is ok. In details the big error I have are in receiving the unsigned long and t...

So setsockopt for timeouts on AF_UNIX (AF_LOCAL) sockets... undocumented/don't work... options/alternatives?

I'm running Fedora 13 if that matters. I looked up man pages on unix(7), setsockopt, and send/recv. Reading the man pages seems to more or less tell me that not all options are guaranteed to do ANYTHING... and apparently only a few that do/don't work are actually documented. In particular... I wanted to see if timeouts were possible. ...

Finding two free tcp ports

I understand that the following code can (perhaps not very efficiently) find out a free TCP port in Java: public static int findFreePort() { int port; try { ServerSocket socket= new ServerSocket(0); port = socket.getLocalPort(); socket.close(); } catch (Exception e) { port = -1; } return port; ...

.NET VB How to have Server Listen on Multiple Ports?

I'm writing a very small and simple server that I want to listen on multiple ports. I'm using the below, but connections to port 8081 are not being accepted - any suggestions what I'm doing wrong? (I actually want to listen on multiple ports, I'm not confusing multiple connections) Public Sub StartServer() Dim ports() As Integer...

Is PHP socket a viable option for making PHP jQuery based chat?

Hello all, I am developing a chat module for drupal. I plan to provide multiple backends for chat message processing. I initially started with AJAX and have now included long polling technique in it. Then I came across ape(ajax push engine) and it looks promising. But it will require server side installation of ape for the chat module t...

Can't communicate via socket on Mac OS X

I'm working on some software that consists of a server and clients on one machine that communicate via local sockets. The server (written in Java) opens a java.net.ServerSocket on port 9000, and the clients (in either Java or Python) have to connect to localhost:9000 to communicate. In Windows and Linux, this works fine. On Mac OS X (...

recvfrom failing with error 11

Hi I am trying out a udpclient program which uses sendto and recvfrom functions. I am setting SO_RCVTIMEO value as 10 seconds for my socket. I am binding the socket to source ipaddress and sourceport. When I check the netstat I can see that there is no other process which is binded with the same values. My bind operation is also succe...

Port forwarding on linux local loop to connect two android emulators

I am trying to communicate between two android emulators for communication , thus I am trying to forward port X to port Y on 127.0.0.1 where port X is the port I am transmitting too and Y is the one I am receiving . Is this possible and if so how do I forward the local ports? ...