BBC BASIC for Windows
Programming >> Communication and Input/Output >> CONNECT TO homeLAN DEVICEs W. MAC/IP
http://bb4w.conforums.com/index.cgi?board=communication&action=display&num=1319563963

CONNECT TO homeLAN DEVICEs W. MAC/IP
Post by dynamic35 on Oct 25th, 2011, 5:32pm

I have a device with a MAC address and , in my home network it has got a fixed IP 10.11.12.2. I know -according to device manual - that a command like "READTIME" into that device should activate it such that it responses like"25-OCT-2011, 20.32" now

I have searched discussions and bbc materials and have not found examples on that kind of programs.

Is there some BBC library routine that can be used here to extablish a connection to LAN addresses like 10.11.12.2 -and then allow a sending of a command like above text message to that device and even wait for the answer.

Thank you very much on any example or link on this area of lan socket programming





Re: CONNECT TO homeLAN DEVICEs W. MAC/IP
Post by admin on Oct 25th, 2011, 9:13pm

on Oct 25th, 2011, 5:32pm, dynamic35 wrote:
Is there some BBC library routine that can be used here to extablish a connection to LAN addresses like 10.11.12.2 -and then allow a sending of a command like above text message to that device and even wait for the answer.

Yes, the SOCKLIB library should allow you to do that:

http://www.bbcbasic.co.uk/bbcwin/manual/bbcwing.html#socklib

Richard.
Re: CONNECT TO homeLAN DEVICEs W. MAC/IP
Post by dynamic35 on Oct 26th, 2011, 11:05pm

Thank You Richard!!

So it was like this with socklib initiated

host$="10.11.12.2"
port$="32102"
maxt%=300
PROC_initsockets
sok%= FN_tcpconnect(host$,port$)
startcmd$="READTIME"
i%=FN_writelinesocket(sok%,startcmd$)

j%=FN_readlinesocket(sok%,maxt%,yrtime$)
PROC_closesocket(sok%)

PRINT "LAN timer display= "; yrtime$
END