sockets

how to connect sockets using static ip java

岁酱吖の 提交于 2021-02-10 11:59:33
问题 I want to know if I can Connect Java sockets using a static IP Address. I've recently bought static IP from my ISP and I want to connect a Client Program that use Java socket with my laptop (as a server). I've tried it before in a closed network and it work normally, but when I've tried it with distributed network it doesn't work. Here is a piece of my code Server : ServerSocket serverSocket = new ServerSocket(5432); Socket client = serverSocket.accept(); Client : Socket socket = new Socket

how to connect sockets using static ip java

别说谁变了你拦得住时间么 提交于 2021-02-10 11:58:53
问题 I want to know if I can Connect Java sockets using a static IP Address. I've recently bought static IP from my ISP and I want to connect a Client Program that use Java socket with my laptop (as a server). I've tried it before in a closed network and it work normally, but when I've tried it with distributed network it doesn't work. Here is a piece of my code Server : ServerSocket serverSocket = new ServerSocket(5432); Socket client = serverSocket.accept(); Client : Socket socket = new Socket

C++ nonblocking sockets - wait for all recv data

痞子三分冷 提交于 2021-02-10 11:49:06
问题 I wasn't running into this problem on my local system (of course), but now that I am setting up a virtual server, I am having some issues with a part of my code. In order to receive all data from a nonblocking TCP recv(), I have this function ssize_t Server::recvAll(int sockfd, const void *buf, size_t len, int flags) { // just showing here that they are non-blocking sockets u_long iMode=1; ioctlsocket(sockfd,FIONBIO,&iMode); ssize_t result; char *pbuf = (char *)buf; while ( len > 0 ) { result

C++ nonblocking sockets - wait for all recv data

↘锁芯ラ 提交于 2021-02-10 11:49:01
问题 I wasn't running into this problem on my local system (of course), but now that I am setting up a virtual server, I am having some issues with a part of my code. In order to receive all data from a nonblocking TCP recv(), I have this function ssize_t Server::recvAll(int sockfd, const void *buf, size_t len, int flags) { // just showing here that they are non-blocking sockets u_long iMode=1; ioctlsocket(sockfd,FIONBIO,&iMode); ssize_t result; char *pbuf = (char *)buf; while ( len > 0 ) { result

Receive data on socket in TIME_WAIT state

不想你离开。 提交于 2021-02-10 06:42:08
问题 What happens, in below scenarios, when a socket in TIME_WAIT receives a segment a) When it receives lost ACK b) When sending node wants to establish another new connection using same src_ip:src_port on the server to same dst_ip:dst_port for which the server already has a TIME_WAIT socket. Will it ignore/drop it, sends a reset or reuse the TIME_WAIT socket? Thanks M 回答1: a) When it receives lost ACK Nothing. b) When sending node wants to establish another new connection using same src_ip:src

Linux TCP socket: client has sent data but server still blocks on read()

断了今生、忘了曾经 提交于 2021-02-10 06:31:34
问题 I have a simple client-server example using TCP socket on Linux. The server listens on the loopback address. The client connects to server and sends some integer plus an "END" string to mark the end of data. Server reads the numbers, add them all and returns the total sum. However, my server sometime blocks on read() even though the client has sent all the data successfully. Here's the code: server.c: #include <stdio.h> #include <errno.h> #include <string.h> #include <unistd.h> #include

Sockets Python 3.5: Socket server hangs forever on file receive

*爱你&永不变心* 提交于 2021-02-10 06:17:15
问题 I'm trying to write a Python program that can browse directories and grab files w/ sockets if the client connects to the server. The browsing part works fine, it prints out all directories of the client. Here's a part of the code: with clientsocket: print('Connected to: ', addr) while True: m = input("Command > ") clientsocket.send(m.encode('utf-8')) data = clientsocket.recv(10000) if m == "exit": clientsocket.close() if m.split()[0] == 'get': inp = input("Filename > ") while True: rbuf =

Java client/server sockets

喜你入骨 提交于 2021-02-10 05:49:09
问题 I'm starting off with java sockets and have strange [lack of] output. Here's my source for the socket methods: Client source code: public void loginToServer(String host, String usnm ) { try { Socket testClient = new Socket(host,1042); System.out.println ("Connected to host at " + host); logString = ("CONNECTED: " + host); outGoing = new PrintWriter(testClient.getOutputStream(), true); outGoing.print("Hello from " + testClient.getLocalSocketAddress()); InputStream inFromServer = testClient

python3 sending files via socket

强颜欢笑 提交于 2021-02-10 05:21:06
问题 everything should be alright, but received file is always being damaged the data is matched without any difference remove the hash tag from print(data) if you want to see binary and compering by yourself .................................................................... .................................................................... server.py import socket, threading, os from time import sleep host, port = '127.0.0.1', 442 class transfer : mysocket = socket.socket(socket.AF_INET,

socket.error: [Errno 10054] An existing connection was forcibly closed by the remote host (python2.7)

十年热恋 提交于 2021-02-09 11:12:29
问题 I have a problem with my socket , it is well functioning but when i close the client / close the client window the server lost the connection ( the server needs to stay open and wait for other connection) while True: rlist, wlist, xlist = select.select([server_socket]+open_client_sockets, open_client_sockets, []) for current_socket in rlist: if current_socket is server_socket: (new_socket, address) = server_socket.accept() open_client_sockets.append(new_socket) print 'new member : ' + str