Skip to content

mushroomsir/socket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

socket

Build Status Coverage Status License GoDoc

Installation and Usage

Install the package with:

go get github.com/mushroomsir/socket

Import it with:

import "github.com/mushroomsir/socket"

and use socket as the package name inside the code.

Features

  • Simple API: use it as an easy way to reuse socket(net.conn)
  • Socket support Ping() func

Example

   // create a new socket pool with an initial capacity of 5 and maximum
   // capacity of 30. The factory will create 5 initial connections and put it
   // into the pool.
   pool, err := socket.NewPool(1, 20, socket.NewFactory(address))
   // now you can get a connection from the pool, if there is no connection
   // available it will create a new one via the factory function.
   socket, err := pool.Get()
   // Ping to detect whether the socket is closed.
   b, err := socket.Ping()

   // close pool any time you want
   pool.Close()

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages