I'm a bit new to C, but I've done my homework (some tutorials, books, etc.) and I need to program a simple server to handle requests from clients and interact with a db. I've gone through Beej's Guide to Network programming, but I'm a bit unsure how to piece together and handle different parts of the data getting sent back and forth.
Fo...
I have a Java nonblocking server that keeps track of all the socket channels in a selector. I then establish 500 connections to the server and send data regularly. Every piece of data the server receives is echoed back to the client.
The problem comes where the test works wonderfully for a couple of hours and then all of the sudden gra...
Hello,
I have a Python Server finally working and responding to multiple command's with the output's, however I'm now having problem's with PHP receiving the full output. I have tried commands such as fgets, fread, the only command that seems to work is "fgets".
However this only recieve's on line of data, I then created a while statem...
Like many people, I can do a lot of things with PHP. One problem I do face constantly is that other people can do it much cleaner, much more organized and much more structured. This also results in much faster execution times and much less bugs.
I just finished writing a basic PHP Socket Server (the real core), and am asking you if you ...
I'm having trouble comparing strings in C (with which I am fairly new to). I have socket on this server application waiting to accept data from a client. In this particular portion of my program I want to be able to execute a MySQL query based on the data received from the client. I want to be able to know when the received data has the ...
Hi,
I am writting a test program for a server. At the test appl , I try to connect a great number of clients to the server, but after a while a get all kind of errors like these :
Connection reset by peer: socket write error or
java.net.SocketException: Connection reset or
java.net.ConnectExceptio...
I have the following Java socket client app, that sends same string to socket server:
import java.net.*;
import java.io.*;
public class ServerClient {
public static void main(String[] args) throws IOException {
System.out.println("Starting a socket server client...");
Socket client = new Socket("XXX.X.XXX.XX", 12001);
BufferedOutput...
What is the right (portable, stable) way to get the ToS byte of a received packet? I'm doing UDP with recvmsg() and on linux I can get the ToS if I setsockopt() IP_RECVTOS/IPV6_RECVTCLASS, but IP_RECVTOS doesn't seem to be available on my BSD systems. What is the right way to do this?
I primarily want this to work on the BSDs and Solari...
In my program I need to create sockets and bind them to listen HTTP port (80). The program works fine when I launch it from command line with sudo, escalating permissions to root. Running under XCode gives a 'permission denied' error on the call to binding function (asio::ip::tcp::acceptor::bind()).
How can I do debugging under XCode?
...
On Solaris, in order to get the msg_control field in struct msghdr and have IPV6_TCLASS I seem to need to define _XPG4_2 and __EXTENSIONS__.
It seems to work if I just define these to 1 before including anything:
#if defined (__SVR4) && defined (__sun)
# define _XPG4_2 1
# define __EXTENSIONS__ 1
#endif
Should I do it this way?
Do I...
What is the windows socket notification sink for? I am currently working with MFC socket and I think I have done something wrong since I get this message at windows shutdown. What could cause this?
Thank you.
Edit:
I am currently working with an application that needs to communicate via sockets. When I shutdown my computer I get a mess...
I have a simple Python script that uses the socket module to send a UDP packet. The script works fine on my Windows box, but on my Ubuntu Linux PC the packet it sends is slightly different. On Windows the flags field in the IP header is zero, but using the same code on Linux created a packet with the flags field set to 4. I'd like to mod...
I wanted to write a server that a client could connect to and receive periodic updates without having to poll. The problem I have experienced with asyncore is that if you do not return true when dispatcher.writable() is called, you have to wait until after the asyncore.loop has timed out (default is 30s).
The two ways I have tried to w...
I need a client-server encryption solution for web transfer, (i.e. signed and encrypted client-side, and verified and decrypted server-side).
I am using HTTP, but SSL is not available due to shared hosting restrictions (my server is a shared host environment).
Looking into alternative solutions, I have decided on OpenPGP using GnuPG. On...
I am trying to write a sample Raw socket program to clear my understanding of raw sockets. I create a Raw UDP socket and then call sendto. My sendto succeeds but I never see the packet received by the other side. I dont have any receive side running so I am relying on Wireshark running on both the sender and receiver.
I am pasting the co...
Hello. From what I understand, each HTTP request uses its own TCP connection (please correct me if i'm wrong). So, let's say that there are two current connections to the same server. For example, client side javascript code triggering a couple of AJAX POST requests using the XMLHttpRequest object, one right after the other, before ge...
I am using the function below inside a thread to receive the byte[] via
socket. Since my machine has two network adaptors it is receiveing the byte[]
two times. I want to skip the subsequent same byte[] received.
What should I do to achive this?
public void Receiver()
{
strMultpileBatchString = "";
string mcastGroup = ...
A third party programm allows me to ask data from his ip:port. I ask the stuff via this classic code. Here is the constructor of my connection class:
public TcpConnection(String adress, Integer port) {
this.adress = adress;
this.port = port;
try {
socket = new Socket(adress, port);
System.out.println("Opening con...
After reading a few related questions I've decided to use the tpl library to serialize my structures in order to send and receive them through sockets. I'm having trouble understanding how to send and receive the tpl images using sockets. I get a segfault error on the server side when I call the tpl_dump function.
I know the sockets ar...
Suppose I have a socket. What is the difference between these two lines of code?
line 1:
os.read(some_socket.fileno(), 1024)
line 2:
some_socket.recv(1024)
...other than the fact that the first one doesn't work on Windows. In other words, can I substitute the second line for the first one? I've got a codebase that hasn't really...