Questions tagged [sockets]

21219 questions
1

votes
1

answer
63

Views

Node.js + Apache - https://localhost:3000/socket.io/ ERR_CONNECTION_REFUSED

I am implementing a simple game in Node.js. I have a client.js for my client side code, and a server.js running on a remote server, which both use sockets to communicate on port 3000 I am also running Apache on port 80, and using ProxyPass in my apache configuration file, to route the url mywebsite....
Barney Chambers
1

votes
1

answer
27

Views

Socket does not send data in while loop

I'm trying to do make simple network communication where a client sends a user input string to the server, which server then displays to the console. When I send only one string, it works fine, but as soon as I wrap my user input code and send code in a while loop, the server receives nothing. SERVE...
Alexandre Ringot
1

votes
2

answer
25.3k

Views

C# An existing connection was forcibly closed by the remote host: socket programming

I am working with sockets. Here are my codes (the description of problem is further): Client side: public void ReadCallback(IAsyncResult ar) { int fileNameLen = 1; String content = String.Empty; StateObject state = (StateObject)ar.AsyncState; Socket handler = state.workSocket; int bytesRead = handle...
Emaad Ali
0

votes
0

answer
17

Views

creating cache for faster access of list of dicts in python

I am writing a python program for getting the ipaddress of the website by using socket module. Here, i have a list of dicts with n number of websites and numbers. Here's some sample data: d = [{'website': 'www.google.com', 'n': 'n1'}, {'website': 'www.yahoo.com', 'n': 'n2'}, {'website': 'www.bing.c...
Smack Alpha
1

votes
1

answer
54

Views

Why isnt my sockets onsubscribe event getting used?

I am using java springboot with maven in order to get the spring boot starter socket package. My clients are using angular with stompjs and sockjs-client. I am trying to set up a simple web socket application that allows for multiple rooms based on a roomId. When a client joins a room they should re...
skyleguy
1

votes
1

answer
1.4k

Views

SocketException: socket closed in accept() on ServerSocket

I had written a small code where I am trying to listen on particular port as follows (just trying out something) : public class Test { public static class MyThread extends Thread { ServerSocket ss = null; public MyThread(int port){ try { ss = new ServerSocket(port); } catch (IOException e) { System....
Furquan Ahmed
1

votes
1

answer
810

Views

select() on STDIN and Incoming Socket

I'm trying to write a very basic chat client in C which communicates with another machine using sockets, and I'm having some issues with understanding select. Here's a quick snippet of the relevant code. while(1) { FD_ZERO(&readfds); FD_ZERO(&writefds); FD_SET(STDIN, &writefds); FD_SET(connectFD, &r...
user3502205
10

votes
0

answer
353

Views

UWP SendToAsync from Socket results in AddressFamilyNotSupported

I am using the Socket class from UWP to send data via UDP to a specific device. The problem is that after a few send forth and back, my SocketAsyncEventArgs for Sending gets stuck and in SocketError i got AddressFamilyNotSupported. Initializing of the classes is done like this m_Socket = new Socket...
Cyriac
1

votes
1

answer
174

Views

Why are Go sockets slower than C++ sockets? [closed]

I benchmarked a simple socket ping pong test in Go and C++. The client begins by sending 0 to the server. The server increments whatever number it gets and sends it back to the client. The client echos the number back to the server, and stops once the number is 1,000,000. Both the client and the ser...
rampatowl
1

votes
2

answer
50

Views

Thread race condition and passing by value in C

I can't quite figure out why this simple network code prevents a race condition int main(void) { ... listen(sd, SOMAXCONN); for(;;) { pthread_t t; int *socket; socket = malloc(sizeof(int)); *socket = accept(sd, NULL, NULL); pthread_create(&t, NULL, service_request, socket); pthread_detached(&t); } ....
Mattz
1

votes
3

answer
170

Views

Python socket module: Recv() data response cut off

Explanation I'm currently trying to control a smart power strip using a python script. To accomplish this, I'm using a TCP connection with the socket module. Around 75% of the time, I get the response/data I was looking for and everything works perfectly. However, around 25% of the time, the respons...
Marco C
1

votes
1

answer
27

Views

TCP Socket HTTP GET Request Content-Length > 0 but not returning actual Content

I am trying to query a REST API service hosted on a Tomcat/Spring Boot application using a TCP Socket instead of an HTTPClient as I cannot use an HTTPClient. I am able to successfully open the Socket, send the request, and receive data from the server but there is never any body or content returned...
mhmmx
1

votes
2

answer
48

Views

How to open socket on a specific IP

I am trying to create a simple server program through C but I don't want it to use my current IP, rather I want to provide a specific IP. But things are not working. As the very first step to provide a specific IP, I removed the following statement from the code: [NOTE]: Here, 'hints' is an object o...
xscorp7
1

votes
1

answer
58

Views

How to close a task waiting on a server socket listen?

I have a program, written in Ada (although for this purpose I'm interested in any solution). It has a task in it that won't shut down without a sigkill (the program handles SIGUSR1) because it's waiting on a server socket it's created. The SIGUSR1 is handled correctly, but this task won't terminate...
David Boshton
1

votes
2

answer
38

Views

How to receive and assemble byte arrays with variable lengths in Python sockets?

I am trying to send large byte arrays of a Protobuf class from a Java client to the Python server. However, they have a variable length, because sometimes I send the bytes of an object from ClassA and sometimes from ClassB. I have a Python socket server with the following code inside the function th...
jazzchipc
1

votes
2

answer
1k

Views

File descriptor of a java datagram socket

How do I get the file descriptor of a Java Datagram socket? I've searched the web without any success. Srini
Srini
0

votes
1

answer
23

Views

Send file size and then the file itself

client-side code: int path = open('text.txt',O_CREAT | O_WRONLY, 0644); if(path < 0){ printf('%s\n',strerror(errno)); } int remain_data = file_size; printf('Printing out the file size '); printf('%d\n',file_size); char *buffer1 = (char*)malloc(sizeof(char)*file_size+1); recv(sockfd,buffer1,BUFSIZ,0)...
laxattack
1

votes
3

answer
7.1k

Views

python socket stays CLOSE_WAIT

i have an application which listen on sockets. this application is monitored by nagios. the problem is, that nagios opens sockets and closes those directly.My application sockets stays in CLOSE_WAIT. And i dont understand why this happens. It should run into an error and kill the socket. while reque...
user1010775
1

votes
2

answer
1.6k

Views

Parsing XML data from Sockets using C

I have a client program which sends the XML data to my server program. The server needs to parse the XML data. I am using C language with Linux. Is there any API available to parse XML from sockets directly? otherwise how could I know whether the XML transfer is completed or not?
Harikrishnan
0

votes
1

answer
12

Views

Using Socket IO and aiohttp for data transfer between node JS and Python

My overall goal is to generate a stream of random numbers in a JavaScript file (which is run using node) and send them to a python script in asynchronous time intervals. Once the numbers are in python, the script will determine if the numbers are even, or not. If they are, the numbers are sent back...
W. Churchill
1

votes
0

answer
166

Views

How to stop reading from stream on a disconnect gracefully?

I have a simple socket connection that runs a read task in async. When I disconnect I get an exception: System.ObjectDisposedException: Cannot access a disposed object. Object name: 'SslStream'. I don't know how to stop it trying to read when it is sitting and waiting to read a message when I call d...
WDUK
1

votes
0

answer
499

Views

How to remove all/single event listners in socket.io

I am using socket.io for realtime functionality in my app with hapijs. When I am trying to add a listner on server side in a hapijs route and if I reload the same route/page 10 times or more then it starts showing me an error (node:9004) MaxListenersExceededWarning: Possible EventEmitter memory leak...
Dimpal Singh
1

votes
1

answer
264

Views

My socket program doesn't print the output

Just getting started with socket programming, I have created the below code and expecting to print some byte data, but it isn't doing that. import socket def create_socket(): s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.ntohl(3)) while True: rdata, address = s.recvfrom(65535) print(rd...
Vignesh SP
1

votes
0

answer
5

Views

Getting error when setting listen() value on my socket

I am trying to allow up to 5 connections to my socket. Thus, I read I need to use the listen() function. To my understanding if I put listen(5), it means there can be at most 5 connections at any given point in time. However, I I try and run my program, I get an error. I am using Python 2.7.13 serve...
Mary
1

votes
0

answer
211

Views

UnicodeDecodeError from python 2 to 3 with .decode() and sockets

Hello i have been working on a Python code which will flash my Arduino over WiFi and i almost have it working im so close. The issue is it was created for Python 2 and i want it to run on the latest python 3. I added .encode and decode to places where socket sends or receives a string. and that work...
Edwin Martin
1

votes
0

answer
56

Views

How to disconnect from one end point and then connect to another? - C#

I have two servers and a client. One server is on the same computer where the client is. I need to disconnect from the local server and connect to the remote one. AutoResetEvent disconnectDone = new AutoResetEvent(false); IPEndPoint localEndPoint = new IPEndPoint(Dns.Resolve(Dns.GetHostName()).Addre...
J. Doe
1

votes
0

answer
198

Views

How to send broadcast data to all clients in a muti-threaded socket server?

I am currently in the process of creating a mutli-threaded chat room in python, however I am having trouble broadcasting data to all of the clients. I am hoping to create a system where one clients sends data to the server, and the server broadcasts the data to the other clients. What I am hoping to...
1

votes
1

answer
72

Views

How to close a socket which is locked in an infinite loop?

I have created a server-client project where the server keeps listening and prints the information. However, when i shutdown the client, the server remains open. The problem is that I need to insert this into another application, and, if the server does not close at first, the application will not o...
André Spironello
1

votes
0

answer
240

Views

How to connect to socket.IO using swift?

I am working with socket io using AppCoda this Tutorial. connect to socket server using node.js and swift, working fine , But it was group chat if we send the message it is showing to all users available in the socket . But How can we send messages one to one I am using socketio/socket.io-client-s...
Bittoo Praveen
1

votes
0

answer
83

Views

Signal handler triggers on first time signal is raised, but not subsequent times

I'm fairly new to signals. It's an AF_INET socket, handling SIGIO. The first connection and packet are received and handled (displayed) properly, as far as I can tell. Subsequent sends are not, however. A breakpoint on the signal handler in GDB (as well as the atomic state flag) shows that the signa...
1

votes
0

answer
44

Views

socket io and lite server issue

i integrated lite-server to my project. One of my page implement socket.io. If any action made of of my browser means same action apply into another browser. For Example, If i scroll or enter some data in to my form means, same data entered into another browser.Please help me. app module import { So...
Deepak M
1

votes
0

answer
26

Views

I am sending an int object on a socket connection but on recieving it, the result is b' '. What can I do to keep it an int object?

This is the client side which is sending the code: import socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) code=123 try: sock.connect(('192.168.1.10',12345)) sock.send(code) print(sock.recv(1024).decode('ascii')) finally: sock.close()
Jodh Singh
1

votes
0

answer
57

Views

Inter process communication between c and PHP using socket

I created socket using c program and Im trying to connect it by a PHP script. and after connection im reading some values from client side, after reading the value and it is displaying on web browser, after displaying the client side(php script) is closing, i want to my php script to hold the same...
Prodigy
1

votes
2

answer
383

Views

How to know the status of tcp connect in python?

In python, tcp connect returns success even though the connect request is in queue at server end. Is there any way to know at client whether accept happened or in queue at server?
Anand
1

votes
0

answer
273

Views

Watch an API Endpoint with Socket.io

Im trying to set up web sockets to monitor changes at an API endpoint. I am able to set up web sockets across my native Node.js server and client. Server: var app = http.createServer(function(req, res){ //... }); var io = require('socket.io').listen(app); io.on('connection', function(socket) { con...
yevg
1

votes
0

answer
115

Views

Can't connect to local MySQL server through socket after system crashed

My laptop suddenly crashed with a BSD and after a restart and logging back in, mysql is causing me problems. I am using vagrant with mysql inside on UBUNTU. [email protected]:/var/lib/mysql# service mysql start Job for mysql.service failed because the control process exited with error code. See 'systemctl s...
Abad Rahman
1

votes
1

answer
55

Views

How can I determine when the network stack is ready to open socket to same host/port again?

I have the following C program whose main function runTCPConnectivityCheck opens a TCP socket, sends a string of bytes to it and closes it: #include #include #include #include #include static int runTCPConnectivityCheck(const int port) { int fd = socket(AF_INET, SOCK_STREAM, 0); if (fd < 0) { p...
Richard Cook
1

votes
0

answer
293

Views

UDP connection - Socket programming in C

I have a specific equipement (IP : 192.168.0.10 port 3000 - it's a signal receiver) that must be controlled through UDP. I should be able to send this equipement basic commands such as 'reset'; 'log' ; 'run' ... After some struggle and the gentle help of stackoverflow i managed to communicate with m...
HacHac
1

votes
1

answer
58

Views

Socket Exceptions due to density in Nodejs with WebSocket

I have node js server that is connected the 10k-14k client with WebSocket. When client count is up to above about ~14k, new clients begin to get the exception that: 'System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it' As far as I know, this...
Qwer Sense
1

votes
1

answer
101

Views

python socket not sending data in windows

I was trying to debug a library for opening ssl sockets in actionscript and encountered a problem with data not being sent through open sockets. I was able to reproduce it from python using this script:- import socket v=socket.socket() v.connect(('127.0.0.1',443)) x='\x16\x03\x01\x00W\x01\x00\x00S\x...
Sonya Roy

View additional questions