sockets

Can I replace AF_UNIX sockets (Linux) with AF_INET sockets (vxworks 5.4)

I have an application in Linux that uses AF_UNIX sockets. I need to port the application to vxWorks 5.4. Can I replace AF_UNIX sockets (Linux) with AF_INET sockets (vxworks 5.4)? If I can replace socket(AF_UNIX,..) in Linux with socket(AF_INET,..) in VxWorks 5.4, please let me know what precautions need to be taken. If example code is ...

I need a script/application to persist TCP connections for a PHP frontend.

Hello, I am making a PHP frontend for a backend server using a custom protocol over TCP. Due to a fairly complex handshake when establishing connections to the backend server, I would like to persist the TCP connections to the backend server. Naturally, given the inherently stateless nature of HTTP (and especially so when using mod_php u...

Efficient mapping of users to sockets

I'm debating on how to map a User struct to their socket file descriptor. I was considering keeping an array of void pointers of a MAX_CONNECTIONS size, and storing the pointer as the value for the key of the file descriptor. The issue I run into is how I plan on handling my receives. I currently call pipe() to make a pipe, and then for...

Best practice for reading until a marker with sockets (Java)?

Hello I'm creating a mobile app to run on a phone and trying to read data from it in the most efficient way. The application will send data to my server app (in the form of bytes, not necessarily characters). I won't know the length of the data; the end will be marked with a 3 byte marker (i.e. 0x11,0x22,0x33), and then a new set of da...

C++ Linux TCP sockets fd

how do i change the socket id/FD after i use accept() ? lets say i bind() on sockfd 3 and the accepted client is on sockfd 4, how do i change/move that sockfd to 1000? OS : Ubuntu ...

TCP handshake phases corresponding to select() and accept() return points

I have a TCP server that creates a (blocking) socket, waits until it is available for reading using select(), then calls accept() and starts reading the data. Here is an example (not mine) illustrating the concept. The question is, at what points of TCP handshake does select() and accept() calls return? Ubuntu Hardy, if it matters. 2...

What is the most efficient way to get java buffer in native code under JNI?

Problem: My code native code (c/c++) is called via JNI. Once it's started it needs to get byte[] buffer from Java object several times per second for further heavy processing. Native code should request buffer when processing of previous buffer is completed. The orginal idea was to pass buffer via AF_INET socket to avoid JNI stuff, b...

Flex Sockets not sending data on Windows

Hi All I really hope someone can shed some light on this. I am building a really simple Chat server/client using PHP and Flex. I have followed many tutorials and have a working server in PHP and a working client in Flex, except that if I use the client on Windows I can't send any messages. When I send a message on my Mac it goes throug...

How to read reply from socket in c?

I'm trying to write a TCP client that does the following things: 1. Establish TCP connection to webserver 2. Accept GET request command from user's console 3. Client should get a reply back from webserver after each GET request. I'm having a difficult time for the 3rd condition. I did not receive any response back from the webserver. ...

socket in python

hello ,,, i tried to do client and server and look what i do #Server import socket Host='' Port=305 OK=socket.socket() OK.bind((Host,Port)) OK.listn(1) OK.accept() and another one for client #Client impot socket Host='192.168.1.4' Port=305 OK=socket.socket() OK.connect((Host,Port)) First thing : for now every thing is ok but i w...

transfering various files one after the other - java sockets

I am writing a socket server, that when the client requests, the server will send some files, one after the other. Supose I have file1, file2, and file3 to be transfered. How can I know on the client side, if the file1 has finished, and file2 has started? For messages I am using a DELIMITER character (\r\n). Should I use thise for files ...

what does 0 indicate in socket() system call?

hi.. what 0 indicates in following line? what are other flags i can use? server = socket(AF_UNIX, SOCK_STREAM, 0) ...

Tell whether a text string is an IPv6 address or IPv4 address using standard C sockets API

I have a program where an external component passes me a string which contains an IP address. I then need to turn it into a URI. For IPv4 this is easy; I prepend http:// and append /. However, for IPv6 I need to also surround it in brackets []. Is there a standard sockets API call to determine the address family of the address? ...

actionscript: connect to socket server

I am using actionscript to connect to my socket server, but I always got <policy-file-request/> sent from actionscript and after that the conneciton is closed. The code in actionscript is: protected function connect_to_server_btn_clickHandler(event:MouseEvent):void { Security.loadPolicyFile("http://192.16...

How do web servers avoid TIME_WAIT?

I'm writing a simple HTTP server and learning about TIME_WAIT. How do real web servers in heavy environments handle requests from thousands of users without all the sockets getting stuck in TIME_WAIT after a request is handled? (Not asking about keep-alive -- that would help for a single client, but not for thousands of different clien...

Non-block vs select() call in socket

I have to implement a game server in C which handles multiple clients and continuously exchange information with them. The client may not be sending information at all times.Should I assign a thread with non-blocking socket to them or use select() call. Which one is better? ...

HttpClient: how do I obtain the underlying socket from an existing connection?

I am using HttpClient 4.02 to create a connection via proxy (using the CONNECT method) to tunnel a connection to a remote server. HttpClient is very convenient for this but I am new to the API and cannot see how to get at the underlying Socket of the tunneled connection. The following code taken from: http://svn.apache.org/repos/asf/htt...

Send ASCII string using HTTP Post

I'm currently sending image data over as a byte array. However, I wish to send it over as ASCII string. How can I send an ASCII string from client to server using HTTP POST in c#? HttpWebRequest webRequest = null; webRequest = (HttpWebRequest)HttpWebRequest.Create("http://192.168.1.2/"); webRequest.ContentType = "applicat...

Data issue connecting from Flex (XMLSocket) to .NET (Socket)

Hi everyone, I'm working on a chat/IM system for my game (which is written in Flex) and wanted to connect it to my server (which is written in C#) via sockets. So, I've successfully connected them together using XMLSocket on Flex, and Socket on the server side, the client gets a connected event, sends data correctly, but when I try to s...

Python persistent socket connection

Hello, I'm new to python :) I would like to create persistent socket. I tried to do this using file descriptors. What I tried is: Open a socket socket connection s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) Get it's file descriptor number fd = s.fileno() Open the file descriptor as I/O os.open(fd) But I get OSError: [Errno ...