Fail to perform simple internet connection


#1

Hi,

I suppose to demonstrate simple TCPIP connection to a remote server and send a string of bytes.
I have tested successfully SMS massage sending and when i tried the sample of the internet connection from the reference manual , i got the following error:

Lua interactive shell
$ =at"at+creg?"
= {
"\r\n+CREG: 2,1,“7A59”,“53E9"”,
“\r\nOK” }
$ wip.bearer_client(“GPRS”, {apn=‘internetg’})
$ x=wip.client_create(“www.google.com”, 80)
run(): error: shell:1: attempt to call field ‘client_create’ (a nil value)
stack traceback:
shell:1: in function ‘?’
?: in function <?:76>
$

Can you please advice what could be possibly wrong?

Thanks,


#2

The command wip.client_create() has been renamed wip.tcp_client(), cf. in the thread Failure to call wip client create.


#3

Thanks , it was working only once but now i get the following

$ wip.tcp_client(“GPRS”, {apn=‘internetg’})
run(): error: bad argument #2 to ‘?’ (number expected, got table)
stack traceback:
[C]: in function ‘?’
?: in function ‘tcp_client’
shell:1: in function ‘?’
?: in function <?:76>
Can you please advice?


#4

wip.bearer_client(“GPRS”, {apn=…}) opens the IP link
wip.tcp_client(“www.google.com”, 80) opens a TCP socket (and needs the IP link to be opened in order to work)

You mixed up the two.


#5

Thanks it works well , now is there any simple code that i can use in order to send some text to a remote ip address using tcpip?


#6

untested code:

wip.bearer_client('GPRS', {...})
ch = wip.tcp_client ('myserver.example.com', 1234)
ch:write ("Hello!\r\n")
response = ch:read '*l' -- read one line, terminated with '\n'
ch:close()
print ("The TCP server has responded: " .. response)

Of course, you need to set up a server on port 1234 of myserver.example.com