Git Product home page Git Product logo

bgreeves-socket-example's Introduction

Sockets Discussion Starter Code

Implement the TODOs in server.c and client.c

During Class: Implement together

  • server.c: Runs a server that listens for messages from clients.
  • client.c: Creates a client that sends a single message to the server.

Helper function

The file helpers.h contains functions to help you set up the sockaddr_in structs for your sockets.

Instructions

Download code

$ git clone https://github.com/eecs482/bgreeves-socket-example.git

Compile examples

The Makefile has recipes to build the client and server programs on CAEN or Mac OS using:

# To build
$ cd starter-code
$ make client
$ make server

# To clean
$ make clean

Run the server and clients

In one terminal, run the server and specify a port to listen on:

$ ./server 8888
Server listening on port 8888...

In another terminal, spawn a client to send a message to the server:

$ ./client localhost 8888 "hello server"
Sending message hello server to localhost:8888

The server should print the message it receives to the terminal:

$ ./server 8888
Server listening on port 8888...
New connection 4
Client 4 says "hello server"

Tip: SSH-ing into the same CAEN machine from different terminals

In order to run a server and a client in two separate terminals over SSH, you have to be connected to the same CAEN machine.

To do this, first, from one terminal, SSH into CAEN normally and determine the hostname of the machine you logged into:

$ ssh [email protected]
$ hostname
caen-vnc-vmXX.engin.umich.edu

Then you can SSH directly into this machine from another terminal:

bgreeves-socket-example's People

Contributors

admuchoor avatar bgr360 avatar xia-steven avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.