aboutsummaryrefslogtreecommitdiff
path: root/misc/main.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-07-23 16:21:46 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-07-23 16:21:46 +0200
commit24d1fba7c5eee9bf8cfd4bd45dcd2127042795c2 (patch)
treea4a34d031cfa35e70cd7e365ad885e7d54a8391e /misc/main.go
parent48bfca18844c69674b865bb9c4e859108aa276a6 (diff)
Implement io.ReadWriter
Diffstat (limited to 'misc/main.go')
-rw-r--r--misc/main.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/misc/main.go b/misc/main.go
index 4639621..dcf9b98 100644
--- a/misc/main.go
+++ b/misc/main.go
@@ -5,7 +5,7 @@ import (
"flag"
"fmt"
"log"
- "net"
+ "io/ioutil"
"dim13.org/asn1/tde"
)
@@ -24,6 +24,7 @@ import (
*/
var service = flag.String("service", "192.168.240.20:33333", "PBX CTI Service")
+var conn tde.TDE
func init() {
flag.Parse()
@@ -207,29 +208,29 @@ func dump(b []byte) {
fmt.Println(hex.Dump(b))
}
-func Ask(c net.Conn, out []byte) []byte {
+func Ask(c tde.TDE, out []byte) []byte {
log.Println("Ask")
dump(out)
- tde.Send(c, out)
- in := tde.Recv(c)
+ c.Write(out)
+ in, _ := ioutil.ReadAll(c)
log.Printf("Packet length: 0x%.2X\n", len(in))
dump(in)
return in
}
-func Status(c net.Conn) {
+func Status(c tde.TDE) {
log.Println("Status")
- in := tde.Recv(c)
+ in, _ := ioutil.ReadAll(c)
log.Printf("Packet length: 0x%.2X\n", len(in))
dump(in)
out := status
out[4] = in[4]
dump(out)
- tde.Send(c, out)
+ c.Write(out)
}
func main() {
- conn := tde.Dial(*service)
+ conn, _ = tde.Dial(*service)
defer conn.Close()
Ask(conn, associate)