sockets

Dispatch action on the callback of socket.on()

故事扮演 提交于 2021-01-27 12:46:33
问题 So basically I got this socket, that is working correctly sending me 'new order' message. I'm using redux, and i want to dispatch an action, than a reducer would get it and my store would be updated. but this code doesn't do anything! socket.on('new order', (order) => { return (dispatch) => { dispatch(socketNewOrder(order)); } }); And here is my action, which is located at the same file: export const socketNewOrder = (order) => { return { type: 'SOCKET_NEW_ORDER', payload: order } } I also

Python socket gethostbyname() returns only one IP address

徘徊边缘 提交于 2021-01-27 11:50:28
问题 Friends, I'm doing some simple experiments using python socket, where I've a HOSTNAME which resolves with two IP addresses but when I use, socket.gethostbyname('demo.sample.com') I'm getting only one IP address. why it's showing that way? is there any other way I can get multiple IP addresses? Please guide me. Thanks in Advance! EDIT - 1 I Got it guys, Instead of gethostbyname('demo.sample.com') I tried gethostbyname_ex('demo.sample.com') It gives the result as i expected. Thanks to All 回答1:

Python socket gethostbyname() returns only one IP address

那年仲夏 提交于 2021-01-27 11:48:47
问题 Friends, I'm doing some simple experiments using python socket, where I've a HOSTNAME which resolves with two IP addresses but when I use, socket.gethostbyname('demo.sample.com') I'm getting only one IP address. why it's showing that way? is there any other way I can get multiple IP addresses? Please guide me. Thanks in Advance! EDIT - 1 I Got it guys, Instead of gethostbyname('demo.sample.com') I tried gethostbyname_ex('demo.sample.com') It gives the result as i expected. Thanks to All 回答1:

how to pass the entire string over the read and write function in TCP socket programming in c program

穿精又带淫゛_ 提交于 2021-01-27 10:40:45
问题 here is sample program to get the month or year or time request from multiple client to server in server program, here i am not able to send "Fri Jan 11 11:59:51 2008" the full string from buffer in server program to client.only Fri alone read in the client. SERVER program #include<stdio.h> #include<sys/types.h> #include<sys/socket.h> #include<netinet/in.h> #include<string.h> #include <unistd.h> #include <fcntl.h> #include<sys/stat.h> #include<time.h> int main(int argc,char **argv) { int len

how to pass the entire string over the read and write function in TCP socket programming in c program

好久不见. 提交于 2021-01-27 10:40:07
问题 here is sample program to get the month or year or time request from multiple client to server in server program, here i am not able to send "Fri Jan 11 11:59:51 2008" the full string from buffer in server program to client.only Fri alone read in the client. SERVER program #include<stdio.h> #include<sys/types.h> #include<sys/socket.h> #include<netinet/in.h> #include<string.h> #include <unistd.h> #include <fcntl.h> #include<sys/stat.h> #include<time.h> int main(int argc,char **argv) { int len

Creating non-blocking socket in python

こ雲淡風輕ζ 提交于 2021-01-27 10:01:07
问题 I was trying to understand how non-blocking sockets work ,so I wrote this simple server in python . import socket s=socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('127.0.0.1',1000)) s.listen(5) s.setblocking(0) while True: try: conn, addr = s.accept() print ('connection from',addr) data=conn.recv(100) print ('recived: ',data,len(data)) except: pass Then I tried to connect to this server from multiple instances of this client import socket s=socket.socket(socket.AF_INET, socket.SOCK

Why is Android dropping TCP packets, occurs in droid 5.x, not in 4.x?

ぃ、小莉子 提交于 2021-01-27 06:48:03
问题 I have an android smartphone connecting via WIFI to an embedded AP. I am sniffing WIFI traffic with a laptop running Tshark on Linux. I am transferring small (234 bytes) TCP packets 5 times every 100ms, followed by 500ms with no data. Periodically, packets will be ignored, forcing retransmission. Some level of packet retransmission is expected when transferring data over TCP sockets, but this is excessive. Especially so because the packets are received by the sniffer without problem (i.e.,

C#: Question about socket programming (sync or async)

喜夏-厌秋 提交于 2021-01-27 06:43:40
问题 I'm writing an instant messaging server in C# for learning purposes. My question is whether I should use synchronous or asynchronous sockets to handle the IM clients. The goal is to handle as many clients as possible. I'm not quite sure but as far as I know with async sockets the packets don't arrive in order which means when you send 2 chat messages and there is a delay/lag it's possible that the second one arrive before the first one. Is this right and if so, is there a way to solve this

C#: Question about socket programming (sync or async)

懵懂的女人 提交于 2021-01-27 06:39:23
问题 I'm writing an instant messaging server in C# for learning purposes. My question is whether I should use synchronous or asynchronous sockets to handle the IM clients. The goal is to handle as many clients as possible. I'm not quite sure but as far as I know with async sockets the packets don't arrive in order which means when you send 2 chat messages and there is a delay/lag it's possible that the second one arrive before the first one. Is this right and if so, is there a way to solve this

How to set linux kernel not to send RST_ACK, so that I can give SYN_ACK within raw socket

时光怂恿深爱的人放手 提交于 2021-01-27 06:21:33
问题 I want to ask a classic question about raw socket programming and linux kernel TCP handling. I've done the research to some same threads like linux raw socket programming question, How to reproduce TCP protocol 3-way handshake with raw sockets correctly?, and TCP ACK spoofing, but still can't get the solution. I try to make a server which don't listen to any port, but sniff SYN packets from remote hosts. After the server do some calculation, it will send back a SYN_ACK packet to corresponding