Giter Site home page Giter Site logo

golang-ipc's Introduction

golang-ipc

Golang Inter-process communication library for Window, Mac and Linux.

Overview

A simple to use package that uses unix sockets on Macos/Linux and named pipes on Windows to create a communication channel between two go processes.

Usage

Create a server with the default configuation and start listening for the client:

	sc, err := ipc.StartServer("<name of socket or pipe>", nil)
	if err != nil {
		log.Println(err)
		return
	}

Create a client and connect to the server:

	cc, err := ipc.StartClient("<name of socket or pipe>", nil)
	if err != nil {
		log.Println(err)
		return
	}

Read and write data to the connection:

        // write data
        _ = sc.Write(1, []byte("Message from server"))
        
        _ = cc.Write(5, []byte("Message from client"))


        // Read data
        for {
            
            dataType, data, err := sc.Read()

            if err == nil {
                log.Println("Server recieved: "+string(data)+" - Message type: ", dataType)
            } else {
                log.Println(err)
                break
            }
	    }


        for {
            
            dataType, data, err := cc.Read()

            if err == nil {
                log.Println("Client recieved: "+string(data)+" - Message type: ", dataType)     
            } else {
                log.Println(err)
                break
            }
	    }

Encryption

By default the connection established will be encypted, ECDH384 is used for the key exchange and AES 256 GCM is used for the cipher.

Encryption can be swithed off by passing in a custom configuation to the server & client start functions.

    
    config := &ipc.ServerConfig{Encryption: false}
	sc, err := ipc.StartServer("<name of socket or pipe>", config)

Testing

The package has been tested on Mac, Windows and Linux and has extensive test coverage.

Licence

MIT

golang-ipc's People

Contributors

james-barrow avatar javea7171 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.