Giter Site home page Giter Site logo

network-go's Introduction

Network module for Go (UDP broadcast only)

See main.go for usage example. The code is runnable with just go run main.go

Features

Channel-in/channel-out pairs of (almost) any custom or built-in datatype can be supplied to a pair of transmitter/receiver functions. Data sent to the transmitter function is automatically serialized and broadcasted on the specified port. Any messages received on the receiver's port are deserialized (as long as they match any of the receiver's supplied channel datatypes) and sent on the corresponding channel. See bcast.Transmitter and bcast.Receiver.

Peers on the local network can be detected by supplying your own ID to a transmitter and receiving peer updates (new, current and lost peers) from the receiver. See peers.Transmitter and peers.Receiver.

Finding your own local IP address can be done with the LocalIP convenience function, but only when you are connected to the internet.

For Windows users

In order to use this module on Windows, you must install a C compiler. I recommend TDM-GCC, which is a redistribution of GCC and MinGW.

You may need to add the C toolchain binaries to your Environment Path manually. If you can run gcc from either cmd or Powershell, it is already working. If not, open the environment variables dialog the long way, or the short way with Win+R and typing rundll32 sysdm.cpl,EditEnvironmentVariables. Edit the PATH variable by adding ;C:\TDM-GCC-64\bin (or whatever your chosen install directory was) at the end of the semi-colon-delimited list. You may also need to restart or log off & back on in order for the changes to take effect.

The error return values on Windows just display numbers instead of descriptive text. See here for descriptions of the error codes


If you are wondering why Windows is such a hassle, read the comments in network/conn/bcast_conn_windows.go

network-go's People

Contributors

klasbo avatar andrineelse avatar kjetilkjeka 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.