~~~After starting run `strace -s 512 -p $(pgrep -f socket)` and `strace -s 512 -p $(pgrep -f serviceDirectory)`~~~
This works now. The `binding` definition was referring to the wrong interface (printerService instead of printService).
#### $GOPATH/src/socket/main.go
```go
package main
import (
"bytes"
"encoding/binary"
"fmt"
"log"
"os"
"time"
"golang.org/x/sys/unix"
)
const (
ProtocolID = "e2533dc76a5bf9ba6b2d3e74d8f95bd6" // /legato/apps/sample/helloIpc/printer.api
ServiceInstanceName = "printer"
MaxMsgSize = 112
msgID_printer_Print = 0
)
type OpenMsg struct {
MaxSize uint32
ProtoID [128]byte
IntfName [128]byte
Wait bool
_ [3]byte // padding
}
const sock = "/tmp/legato/serviceDirectoryClient"
func main() {
fmt.Println("strace -s 512 -p ", os.Getpid())
time.Sleep(10 * time.Second)
os.MkdirAll("/data/le_fs/", 0777)
fd, err := unix.Socket(unix.AF_UNIX, unix.SOCK_SEQPACKET, 0)
if err != nil {
log.Fatal(err)
}
sa := &unix.SockaddrUnix{Name: sock}
if err := unix.Connect(fd, sa); err != nil {
log.Fatal(err)
}
openMsg := &OpenMsg{
MaxSize: MaxMsgSize + 4,
Wait: true,
}
copy(openMsg.ProtoID[:], []byte(ProtocolID))
copy(openMsg.IntfName[:], []byte(ServiceInstanceName))
var b bytes.Buffer
if err := binary.Write(&b, binary.LittleEndian, openMsg); err != nil {
log.Fatal(err)
}
_, err = unix.SendmsgN(fd, b.Bytes(), nil, nil, 0)
if err != nil {
log.Fatal(err)
}
buf := make([]byte, 4)
n, _, _, _, err := unix.Recvmsg(fd, buf, nil, 0)
if err != nil {
log.Fatal(err)
}
buf = buf[:n]
log.Print("resp: buf: %#v", buf)
log.Print("Done")
}
```
#### $GOPATH/src/socket/Makefile
```
build:
GOOS=linux GOARCH=386 go build
pkg: build
mkapp -v -t virt socket.adef
install: build
scp -P 10022 socket socket.*.update root@localhost:
```
#### $GOPATH/src/socket/socket.adef
```
sandboxed: true
version: 1.0.2
bundles:
{
file:
{
[x] socket /bin/
}
}
processes:
{
run:
{
( socket )
}
}
extern:
{
requires:
{
printer = $LEGATO_ROOT/apps/sample/helloIpc/printer.api
}
}
bindings:
{
*.printer -> printServer.printer
}
```