sockets

python public ip with sockets (err:cannot assign requested addr)

折月煮酒 提交于 2021-01-29 10:40:31
问题 After allowing my raspberry pi to access port 9999 of my router socketname.bind(96.231.140.202,9999) in python gives me a cannot assign error To port forward I used: myfiosgateway.com/#/firewall/portforward (the same method worked fo my apache server) and I have verified that 96.231.140.202 is my pub ip 回答1: You cannot bind to your public IP. Your router is doing that. You instead want to bind to your private IP and port forward traffic destined to 9999 to your bound IP on your pi, this

POSIX: Return value from write() on UDP socket

你说的曾经没有我的故事 提交于 2021-01-29 10:29:38
问题 On a POSIX system, if sock_fd is an UDP socket, will write(sock_fd, data, size) always return size or -1? I.e., if write() does not fail, will the requested chunk of data always be written in its entirety, implying that, if the return value is not -1, then I can always ignore the actual return value? It seems to me that this should be the case, but no man page seems to state it clearly. EDIT: I suppose there are two possible answers. Either it is stated somewhere, but I haven't found it, or

Socket error on client <>, disconnecting with Paho MQTT-SN Gateway and ESP8266 CLient

痞子三分冷 提交于 2021-01-29 10:00:27
问题 I'm trying to test MQTT-SN. I'm using Mosquitto Broker, Paho MQTT-SN Gateway and this library (https://github.com/S3ler/arduino-mqtt-sn-client) for the clients. I'm using an esp8266 as a client. With this client, I can connect, subscribe, receive from subscribed topics but I cant publish into topics memset(buffer, 0x0, buffer_length); mqttSnClient.publish(buffer, publishTopicName , qos); Every time I try to publish with this client, Mosquitto gives me Socket error on client <clientid>,

pread and lseek not working on socket file descriptor

给你一囗甜甜゛ 提交于 2021-01-29 08:17:18
问题 This question is on system calls pread and lseek . I have a file descriptor of socket type . Data is added to it whenever packet is read from the network layer . I would like to know whats the amount of data present in the file descriptor at regular intervals . I tried using the systems calls pread and lseek , so that I know only the amount of data rather than reading data itself . But , both the calls fails giving Illegal seek error. Are there any other systems calls on the socket type file

How to make server client autodiscover over a lan

最后都变了- 提交于 2021-01-29 07:52:11
问题 I have two project "Server" and "Client" that communicate over a LAN, this my server code using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Net; using System.Net.NetworkInformation; using System.Net.Sockets; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace ServerClientProject { public partial class FormServer : Form { private static Int32

Bind all client sockets to wifi interface

拜拜、爱过 提交于 2021-01-29 07:45:14
问题 I'm writing a client application for my action camera. There's an issue using network connections when smartphone connected to wifi and mobile network: Android determines, that wifi does not connected to internet, so all requests passed to mobile network interface. I've already implemented the client API, that uses pre-bounded sockets to communicate with camera: public class MainActivity extends AppCompatActivity { private Network wifi; @Override protected void onCreate(Bundle

How to listen to an event using sockets?

二次信任 提交于 2021-01-29 06:26:49
问题 We are trying to add play/pause/record buttons to a webpage that shows a video stream. The video is streaming from the server and the webpage is on the client-side. Now the client can see the video stream on the webpage, but we wanted to add some buttons. This is the code that sends the video using sockets: void stream(cv::Mat* frame){ TCPServer serverInputConnection("localhost", 8080); serverInputConnection.createListener(); ////////////////////// reconnect network cycle ////////////////////

ssl server and client using python - client is closing the connection due to exception

不打扰是莪最后的温柔 提交于 2021-01-29 05:42:54
问题 I am newbie to socket and ssl programming in python. Current requirement is that, Client and server shares the pre-shared key so the certificate exchange,authentication and verifying is not needed in both ends. So,during handshake mechanism , there is no need to authenticate the server from client part but the minimal check is that Cipher suites needs to be send along with random number from client is > TLS_PSK_WITH_SHA256 and will be acknowledged by server. In this case, i have created a

Python cannot bind my external/public ip address using socket, gives error But when using local ip address the error doesn't show up

…衆ロ難τιáo~ 提交于 2021-01-29 05:38:24
问题 Here is the code where the main error shows up s.bind(("192.168.1.4", port)) this will work s.bind(("99.99.999.999", port)) lets say used my public ip than itll throw error s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) port = 6767 try: s.bind(("192.168.1.4", port)) #will work fine as local ip is used but #when used public ip the error is thrown except socket.error as e: print(str(e)+"aa") s.listen(2) [WinError 10049] The requested address is not valid in its context 回答1: You can only

How can I interrupt a recvfrom() call in Python with keyboard?

久未见 提交于 2021-01-29 04:13:14
问题 I have a loop running in the main() function of my program that looks as follows while True: data, addr = sock.recvfrom(MAX_MESS_LEN) thread.start_new_thread(message_handler, (data, addr,)) I would like to introduce functionality that allows me to perhaps hit 'q' to break out of the loop and end the program. I'm not sure how to do this since the program waits on the recvfrom() call until receiving a message. Is there a way to implement an interrupt key or keyboard event catcher or something?