aboutsummaryrefslogtreecommitdiff
path: root/spdu
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-10-02 13:45:12 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-10-02 13:45:12 +0200
commit8d04fcaf4b28153227ddc2b6df995468ffeb356a (patch)
tree9312ca531b94a939936cf6a18233b3cd5263fe6e /spdu
parenta35af432542e9797ee4946aa999616643ce49b71 (diff)
Make lint happy, minor formating
Diffstat (limited to 'spdu')
-rw-r--r--spdu/spdu.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/spdu/spdu.go b/spdu/spdu.go
index 7d1992b..bf4c2da 100644
--- a/spdu/spdu.go
+++ b/spdu/spdu.go
@@ -1,4 +1,4 @@
-// SPDU (Session Protocol Data Unit)
+// Package spdu (Session Protocol Data Unit)
package spdu
import (
@@ -14,8 +14,10 @@ import (
const maxLen = 240 // max PDU size
+// Conn spdu
type Conn struct{ net.Conn }
+// Write spdu
func (c Conn) Write(p []byte) (n int, err error) {
size := uint16(len(p))
if size > maxLen {
@@ -27,6 +29,7 @@ func (c Conn) Write(p []byte) (n int, err error) {
return c.Conn.Write(p)
}
+// Read spdu
func (c Conn) Read(p []byte) (n int, err error) {
var size uint16
if err := binary.Read(c.Conn, binary.BigEndian, &size); err != nil {
@@ -35,12 +38,14 @@ func (c Conn) Read(p []byte) (n int, err error) {
return c.Conn.Read(p[:size])
}
+// ReadAll spdu
func ReadAll(r io.Reader) ([]byte, error) {
p := make([]byte, maxLen)
n, err := r.Read(p)
return p[:n], err
}
+// Dial spdu
func Dial(service string) (Conn, error) {
conn, err := net.Dial("tcp", service)
if err != nil {