Coder Social home page Coder Social logo

sockets's Introduction

code for creating sockets

for teaching/learning about sockets the underlying TCP transport layer comms channel for all internet protocols

echo

see server.py the process logs to socket.log (appends, you may have to delete old)

server side

  • run in background ./server.py &
    • binds to 127.0.0.1:8111
    • check it with netstat -lan |less note the state LISTEN
    • if it crashes or has just ended the ip&port may still be bound, in a TIME_WAIT status instead of LISTEN, you can see this through netstat, you will have to wait for it to end

client side, talk to server

  • fake out client comms with netcat nc -v -n 127.0.0.1 8111
    • will echo the data you type in back at you
    • quit will end the connection
    • check the socket source & dest while you are talking to the server `netstat -lan|les

Questons:

To answer these you may need to have a couple of terminal sessions open, it's easier.

Running the server as is

  1. Can you talk to it from another user on the same box? Why or why not?
  2. Can you talk to it from another box? Why or why not?
  3. Can you run the server code many times in the background? Why or why not?

Copy the code to server2.py, change the port, choose a port in the range 8000-8999 that you are not using. 2. run both ./server.py & and ./server2.py & at the same time, in the background 3. does it work? Why or why not? 4. can you talk to each of them, using nc what do you need to change to talk to the 2nd server

sockets's People

Contributors

campbe13 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.