Python Forum
client A to server B connects but client B to server A doesnt connect
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
client A to server B connects but client B to server A doesnt connect
#1
Hi everyone,

Computer A is connected by cable and computer B is connected by WIFI. When I run a server on computer A I can receive a string message sent from computer B.

However, when I host a server on computer B, running the same scripts, I can't receive a string message from computer A. The ip number shown in the examples is that of my WIFI server which doesn't receive a message.

Both computers run Linux Ubuntu -> xfce

client: (computer A connected by inet cable)
    
def Client(self): 
        server_ip,server_port = "10.0.0.16",7000 
        client_socket = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
        while True:
            message="message received"
            client_socket.sendto(message.encode(),(server_ip,server_port))
            break
        client_socket.close()
server: (Computer B connected by WIFI)
import socket

if __name__ == '__main__':  
    BinanceBuy = ""
    server_ip="10.0.0.16"
    server_port=7000

    server_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    server_socket.bind((server_ip,server_port))

    while True:
        data,client_adress = server_socket.recvfrom(1024)
        message=data.decode().strip()
        print(f'received word = {message}') # no message is shown when I run this server script on my WIFI computer
It doesn't give me an error, it's just that it doesn't display the string message sent from computer A.
Any help would be much appreciated !
Reply
#2
Try the example in the Python documentation where the server performs the sequence socket() bind() listen() accept() and the client performs the sequence socket() connect().
« We can solve any problem by introducing an extra level of indirection »
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Running script from remote to server invisiblemind 4 637 Mar-28-2025, 07:57 AM
Last Post: buran
  Changing client.get() method type based on size of data... dl0dth 1 666 Jan-02-2025, 08:30 PM
Last Post: dl0dth
Exclamation Date format convert problem for SQL server eotret 5 1,945 Aug-09-2024, 07:19 AM
Last Post: Pedroski55
  Need Assistance with Creating an AI Chatbot for Client's Website LauraB 4 1,226 Aug-08-2024, 06:00 AM
Last Post: Siska
  How can I upload a .gz file to the Swift Object Storage using Python swift client? Hanginium65 0 725 Jul-24-2024, 03:24 PM
Last Post: Hanginium65
  Sending email using own smtp server robertkwild 11 5,604 Jul-05-2024, 12:59 AM
Last Post: AdamHensley
  (solved) Downnload images from a server and rename charled 13 3,031 Jun-20-2024, 08:16 AM
Last Post: charled
  Connecting to Remote Server to read contents of a file ChaitanyaSharma 1 3,219 May-03-2024, 07:23 AM
Last Post: Pedroski55
  501 Server cannot accept argument anna17 0 921 Apr-11-2024, 01:08 AM
Last Post: anna17
Question [SOLVED] Tiny web server as standalone executable? Winfried 0 1,117 Feb-09-2024, 11:48 AM
Last Post: Winfried

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020