sockets

which protocol used for developing a chat application over LAN?

Hi I would like to create a chat application(desktop-app) in c++, so which protocol i would need to study and implement. UDP(?) Please provide me some good thoughts and advices and links also. ...

Python Socket Send Buffer Vs. Str

I am trying to get a basic server (copied from Beginning Python) to send a str. The error: c.send( "XXX" ) TypeError: must be bytes or buffer, not str It seems to work when pickling an object. All of the examples I found, seem to be able to send a string no problem. Any help would be appreciated, Stephen import socket import pic...

Java SSL sockets without authentication or stores?

I have two java applications that need to talk to each other over an encrypted TCP socket, but they don't need to authenticate each other (one will accept() a connection from the other). Can anyone point me to a tutorial/code-snippet that will help me set these up? I'm looking for something fairly simple and I'd like to not have to supp...

Best practice to find out the closest AD server in the netwrok and to find if the server is dead.

Whats the best way of finding the closest server in the network from the list of servers. I have 2 servers in different locations and through code I want to connect to the one which is closest to where the application is deployed (in terms of connection time). Also whats the best way to find out if a server is down keeping in mind that...

Can read() function on a connected socket return zero bytes?

I know that read() is a blocking call unless I make the socket non-blocking. So I expect read() call which requests 4K of data should return a positive value ( no of bytes read) or -1 on error ( possible connection reset by client etc). My question is: Can read() return '0' on any occasion? I am handling the read() this way: if ((r...

How to listen a socket in Tomcat(servlet container)?

I have to let an web application to listen a socket(ServerSocket), and handle the socket stream. But the application is just deployed in Tomcat which is just a servlet container, it doesn't have JCA support. And establishing a server socket in servlet thread is unreasonable. solution 1: The ugly solution is to write a standalone java ...

How to detect socket Exception when internet connection is not there

Hi I have created a socket server and client program. My socket server is running on different computer and in my computer socket client is there. It works fine But the problem is that if there is no internet connection from the beginning in client computer then during I create socket connection I gets error. only once i will create ...

Android Socket connection refused

I am trying to open a Socket on Android but everytime I try I keep getting connection refused error no matter what way I try. The error happens on the following line of code where I try to create the connection. Socket socket = new Socket(getLocalIpAddressString(), 8008); The following is the method I use to get the local ip addr...

Tcp Socket Closed

I always thought that if you didn't implement a heartbeat, there was no way to know if one side of a TCP connection died unexpectedly. If the process was just killed on one side and didn't exit gracefully, there was no way for the socket to send FIN or let the other side know that it was closed. (See some of the comments here for examp...

how to print a char from struct

Hi Could someone please tell us to print a char when receiving data as a struct? Here is an example: ... struct rcv{ int x1; float x2; char *x3; }; rcv data_rcv; ... if (recv(socket, &data_rcv, sizeof(data_rcv), 0) < 0) printf("recv() failed"); ... printf("x1 = %d\n", data_rcv.x1); printf("x2 = %f\n", data_rcv.x2); printf("x...

Using socket API on IPhone

Hi, for a little project I have to do the following task on my IPhone: open a TCP socket send a command to the server shutdown the WRITE part of the connection read the response from the server close the connection I'm not experienced with socket programming - I've just started with network programming and I've already used the CFSt...

How to detemine which network interface (ip address) will be used to send a packet to a specific ip address?

I'm writing a SIP stack, and I need to insert an ip address in the message. This address needs to be the one used for sending the message. I know the destination IP and need to determine the NIC (its address) that will be used to send the message.... ...

How can I tell Perl's IO::Socket::INET which interface to use?

I have two interfaces on my server, eth0 and eth0:0. Those are two different external IP addresses and obviously two different reverse domains. When I open a IO::Socket::INET connection, Perl uses the eth0 interface by default. I would like to use the second interface (eth0:0) because this has a different IP and I dont want to use my ma...

python blocking sockets, send returns immediately

Hi, I am writing a multithreaded socket application in Python using the socket module. the server listens for connections and when it gets one it spawns a thread for that socket. the server thread sends some data to the client. but the client is not yet ready to receive it. I thought this would have caused the server to wait until the ...

what are needed to make my own SNMP Agent and server??

Hii, I want to make my own snmp server and agent.with my own MIB and OID's. how can i do it??and where to start?? And if i want to use windows SNMP service and extend it and insert my own OID's into its MIB then ,is it possible??.n if yes,how can i do this?? ...

how to send classes defined in .proto (protocol-buffers) over a socket

Hi, I am trying to send a proto over a socket, but i am getting segmentation error. Could someone please help and tell me what is wrong with this example? file.proto message data{ required string x1 = 1; required uint32 x2 = 2; required float x3 = 3; } xxx.cpp ... data data_snd, data_rec; //sending data ...

libevent buffered events and half-closed sockets

It is simple to implement a TCP port mapper using bufferevent_* functions of libevent. However, the documentation states that "This file descriptor is not allowed to be a pipe(2)" and I doubt if it can handle the case of when we can only read or only write to a file descriptor. Will libevent work correctly if the socket is shutdown in ...

Raw socket sendto() failure in OS X

When I open a raw socket is OS X, construct my own udp packet (headers and data), and call sendto(), I get the error "Invalid Argument". Here is a sample program "rawudp.c" from the web site http://www.tenouk.com/Module43a.html that demonstrates this problem. The program (after adding string and stdlib #includes) runs under Fedora 10 b...

Put a java socket-like program in a cloud service

I developed a server side java program, basically is a relay server so I can easily pass NATs and firewalls. The program works, but now I need a cloud service to host it. Do you know where/how I can put a java socket-like program in the cloud? Obviously, I prefer a free service or at least a free service while I'm testing. Thank you! ...

How the clients (client sockets) are identified?

To my understanding by serverSocket = new ServerSocket(portNumber) we create an object which potentially can "listen" to the indicated port. By clientSocket = serverSocket.accept() we force the server socket to "listen" to its port and to "accept" a connection from any client which tries to connect to the server through the port associat...