Skip to content

pepnova-9/go-websocket-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

This is a simple websocket server implementation from scratch. I implemented this for my presentation about WebSocket in CS544 Computer Network 2 class. Slide: https://docs.google.com/presentation/d/1kmqNh6qm5QAQaxlluP0yyOO9PyvrsIAL988sH_3zIsY/edit?usp=sharing

Usage

If you haven't installed Go yet, please download and install it from https://golang.org/dl/. Or simply brew install go if you are using macOS with Homebrew.

Build and run the server

go build -o go-websocket
./go-websocket

Access http://localhost:8080 in your browser. Open your browser console and run the following code to send and receive messages

let ws = new WebSocket("ws://localhost:8080");

ws.onmessage = msg => console.log("Received:", msg.data);

ws.send("Hello, Server!");

// 270 bytes
ws.send("Hello, Server! Hello, Server! Hello, Server! Hello, Server! Hello, Server! Hello, Server! Hello, Server! Hello, Server! Hello, Server! Hello, Server! Hello, Server! Hello, Server! Hello, Server! Hello, Server! Hello, Server! Hello, Server! Hello, Server! Hello, Server! ");

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages