Shaun Jackman <email@example.com> wrote:
I’ll answer my own question as I just figured it out. There’s no need to
create another thread. Just use message_attach() to register a specific type
of message that you’ll receive. Then ion->reg() a down-producer. This will
create the file /dev/io-net/myprotocol0. The client can then simply call
coid = open( “/dev/io-net/myprotocol0”, O_RDRW);
MsgSend( coid, …);
to send packets to the io-net driver. The driver can then tx_down() the
packets to send them.
Receiving up packets is a little trickier. The way I handled it was to
pulse_attach() a special pulse message. When a client wants to receive
packets it creates a channel, and then sends the channel id in the pulse to
the io-net driver. The io-net driver then ConnectAttach()es to the client.
When the io-net driver receives a packet, it MsgSend()s to the channel that
it opened previously.
That is not the “proper way”. You should check for “MsgDeliverEvent”.
The client will create channel, connect attach to the channel, (got
a coid), and prepare a “event”.
The client then send the event to the server, tell server “if
happened, deliver this event back to me”.
Hope somebody finds this useful.