obtaining gateway address

For an app I need to obtain the gateway address of the active connection.

I’m now using this but does anyone have a more neat way that perhaps would also work in iOS?

[code] Dim sh As New Shell
sh.Execute("route -n get default ")
dim answer as string = sh.Result
dim n as integer = instr(0,answer,“Gateway:”)+8
dim last as integer=instr(n,answer,chr(10))-1
dim IP as string= mid(answer,n+1,last-n)

MsgBox IP[/code]

Thanks in advance.

dim sh as new Shell
sh.Execute "route -n get default"
dim answer as string = sh.Result

dim rx as new RegEx
rx.SearchPattern = "gateway: *(\\d+\\.\\d+\\.\\d+\\.\\d+)"
dim match as RegExMatch = rx.Search( answer )
dim ip as string = match.SubExpressionString( 1 )


@Kem Tekinay
Lol, that is indeed more neat, but what I meant is a way that would not require a shell

You’ll have to see if there are any declares to do it on iOS, but I’m not opposed to using the Shell for convenience as long as you’re using tools you are sure will exist on a normal installation, provide those tools yourself in the installation, and are prepared to handle errors in either case.