File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ import  socket 
2+ 
3+ clientsocket =  socket .socket (socket .AF_INET , socket .SOCK_STREAM )
4+ 
5+ 
6+ host =  socket .gethostname ()
7+ 
8+ port =  444 
9+ 
10+ clientsocket .connect ((host , port ))
11+ 
12+ message =  clientsocket .recv (1024 )
13+ 
14+ clientsocket .close ()
15+ 
16+ print (message .decode ('ascii' ))
Original file line number Diff line number Diff line change 1+ this is a client-server system, which uses tcp/ip and sockets to operate
Original file line number Diff line number Diff line change 1+ import  socket 
2+ 
3+ serversocket = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
4+ 
5+ 
6+ host =  socket .gethostname () #gets the IP Address of the host 
7+ port =  444 
8+ 
9+ serversocket .bind ((host , port ))
10+ 
11+ serversocket .listen (3 )
12+ 
13+ while  True :
14+     clientsocket , address =  serversocket .accept ()
15+     
16+     print ("recieved connection from"  %  str (address ))
17+ 
18+     message = 'hello! thankyou for connecting to the server' + "\r \n " 
19+     clientsocket .send (message .encode ())
20+ 
21+     clientsocket .close ()
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments