sockets

FTP upload via sockets

Hello, how can I upload a file with sockets to a ftp server? I am reading something with "STOR" in RFC...It is the same how i transfer a file between two computers?A sample code would be helpfuly...thanks ...

Nonblocking Tcp server

It's not a question really, i'm just looking for some guidelines :) I'm currently writing some abstract tcp server which should use as low number of threads as it can. Currently it works this way. I have a thread doing listening and some worker threads. Listener thread is just sits and wait for clients to connect I expect to have a sin...

pop3 multiline problem

hi everyone, i'm making a client for pop3 and somehow i can't figure out how to handle multiline responses. There is no difference in the response from server whether it is single or multiline, it always ends with CRLF (considering the usual case) so how do I know if I should call recv() once more? ...

Winsock tcp/ip Socket listening but connection refused, race condition?

Hello folks. This involves two automated unit tests which each start up a tcp/ip server that creates a non-blocking socket then bind()s and listen()s in a loop on select() for a client that connects and downloads some data. The catch is that they work perfectly when run separately but when run as a test suite, the second test client w...

select always returns -1 while trying to read from socket and stdin

Hello I have the following code implemented on C++(Linux) to check on my listening socket and stdin using select. select however keeps returning -1 no matter what I try to do! What's wrong with that code :s I will appreciate any help. Thanks highsock = m_sock; //listening socket memset((char *) &connectlist, 0, sizeof(connectlist)); m...

[Python] Socket: Get user information

How can I get information about a user's PC connected to my socket ...

Why is a non-blocking TCP connect() occasionally so slow on Linux?

I was trying to measure the speed of a TCP server I'm writing, and I've noticed that there might be a fundamental problem of measuring the speed of the connect() calls: if I connect in a non-blocking way, connect() operations become very slow after a few seconds. Here is the example code in Python: #! /usr/bin/python2.4 import errno imp...

problem with kCFSocketReadCallBack

Hello. I have a problem with my program. I created a socket with "kCFSocketReadCallBack. My intention was to call the "acceptCallback" only when it receives a string to the socket. Instead my program does not just accept the connection always goes into "startReceive" stop doing so and sometimes crash the program. Can anybody help? Thanks...

Java blocking socket returning incomplete ByteBuffer

I have a socketChannel configured as blocking, but when reading byte buffers of 5K from this socket, I get an incomplete buffer sometimes. ByteBuffer messageBody = ByteBuffer.allocate(5*1024); messageBody.mark(); messageBody.order(ByteOrder.BIG_ENDIAN); int msgByteCount = channel.read(messageBody); Ocasionally, message...

Python: unix socket -> broken pipe

I'm trying to get Python socket working as an alternative to calling the command line socat. This socat command works fine: echo 'cmd' | sudo socat stdio <path-to-socket> but when I run this python code, I get an error: >>> import socket >>> s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) >>> s.connect(<path-to-socket>) >>> s....

How to discover web servers on a local network?

Suppose I'm running several servers serving basic requests on my local network (say a home network, where all machines generally have an IP in the form K.K.K.x, where x is variable). Is there an easy way to discover all such servers? I would need to find each IP on the network running a particular java server application. ...

How to Broadcast to a shutdown system using java?

We use socket.send(packet) function in java to send a "packet" to a given port. My problem is that i have to send a packet to a shutdown system using UDP protocol. The problem with send() function is that first it verifies whether the host IP is multicast or not. Now my local area network is of broadcast type. So i am having problem is...

How do I set the socket timeout in PHP?

I need to set timeout on client.recv in TCP server. ...

How to set timeout on python's socket recv method?

I need to set timeout on python's socket recv method. How to do it? ...

java socket to read content of webpage

Is it possible to use java socket API to read content of a webpage, ex: "www.yahoo.com"? Can somebody here show an example? And how about reading content of a page protected by the web app login screen? Thanks in advance, dara kok ...

Making a function call performed from a static function, do something after return

This is for the purpose of a client/server program. The client asks for some data off the server, and receives it. Upon receiving this data from a Boost socket on the client side, I handle this message in a static method called parse_message in a class called client_protocol. This method, given this specific data, will start a process o...

android: implementation and make listener to a socket

hey everybody, i'm devlopping an application for android, i need to make a session between client(cell phone) and e web server (apache) and keep alive this session to receive notification from the server for this i may implement socket also make a listener for this socket to notify the client if a file is ready to download, after recei...

php socket servers, actionscript 3 and multiplayer

So I am thinking about creating a multiplayer game and I was wanting to use php because I already have a php server. Is it possible to make a socket server that will be able to handle a actionscript multiplayer game. The game won't be big. so we wont need any huge amount of data pushing through. just some software that is probably reliab...

ruby socket dgram example

I'm trying to use unix sockets and SOCK_DGRAM in ruby, but am having a really hard time figuring out how to do it. So far, I've been trying things like this: sock_path = 'test.socket' s1 = Socket.new(Socket::AF_UNIX, Socket::SOCK_DGRAM, 0) s1.bind(Socket.pack_sockaddr_un(sock_path)) s2 = Socket.new(Socket::AF_UNIX, Socket::SOCK_DGRAM,...

recv returns old data

This loop is supposed to take data from a socket line by line and put it in a buffer. For some reason, when there is no new data to return, recv returns the last couple lines it got. I was able to stop the bug by commenting out the first recv, but then I cant tell how long the next line will be. I know it's not a while(this->connected)...