Using ip6 instead of ip4 with Socket

Post your Gambas programming questions here.
Post Reply
User avatar
Cedron
Posts: 156
Joined: Thursday 21st February 2019 5:02pm
Location: The Mitten State
Contact:

Using ip6 instead of ip4 with Socket

Post by Cedron »

It's been a bit problematic for me. Rather than struggle more, I thought I'd ask. I have a home network with hard coded 192.168.$$$.$$$ addresses. I have a Gambas TCP server I coded that I can log into with either a Gambas client I coded, or plain old telnet. With localhost, raw ip addresses, or /etc/hosts entries I can get them to work on the same machine or across my network. Not so much with iv6.

I was able to get ping to work by appending a %2 to the end of the long colon separated addresses shown by ifconfig. I've messed around a bit with bracket formats, but I can't get telnet or my client to connect using the ip6 addresses. (fe80::f28b.....)

Has anybody done this?
.... and carry a big stick!
User avatar
sadams54
Posts: 141
Joined: Monday 9th July 2018 3:43am
Contact:

Re: Using ip6 instead of ip4 with Socket

Post by sadams54 »

I think I am going to do what I complain about and hate when asking for help. And that is when the reply is a bit fat "WHY?"

why do you need to use IPv6? are you exceeding the IPv4 limits in your home network? I can understand using IPv6 in larger commercial networks but for a network of 200 or less clients I can't see why you would not just use IPv4.

The ability to use IPv6 may not be available in the language ( I am not sure on that), but if you can let us know the reasoning for IPv6 I am sure you will get the help you need or be given a way to work around the issue.
User avatar
Cedron
Posts: 156
Joined: Thursday 21st February 2019 5:02pm
Location: The Mitten State
Contact:

Re: Using ip6 instead of ip4 with Socket

Post by Cedron »

Because I am FEARLESS!

Just kidding.

Both telnet and ping have -6 options. Ping works without applying it, I have yet to get the telnet to work to my open port. I don't have telnet server installed (nor do I want to).

I am writing a peer to peer application, prototyping and testing on my isolated LAN, wanting it to be fully capable externally.

I am leaning towards the suspicion that Gambas Socket doesn't support it, or there would be some mention in the documentation.
.... and carry a big stick!
User avatar
sadams54
Posts: 141
Joined: Monday 9th July 2018 3:43am
Contact:

Re: Using ip6 instead of ip4 with Socket

Post by sadams54 »

ipv4 and v6 are very different if you have not noticed just looking at the addresses. I would bet that v6 is not supported and the reason is that v4 is not going away and will likely outlive all of us. I would bet that if you write for v4 you will not have any issues. v6 is usually something handled by the ISP and should not enter into consideration for your projects.

I do understand that you want to learn and experiment but you may not be able to for this.

I am curious about the project and what it does and the reason for its existence. I might have some ideas for you.
User avatar
Cedron
Posts: 156
Joined: Thursday 21st February 2019 5:02pm
Location: The Mitten State
Contact:

Re: Using ip6 instead of ip4 with Socket

Post by Cedron »

sadams54 wrote: Tuesday 7th March 2023 1:08am ipv4 and v6 are very different if you have not noticed just looking at the addresses.
True dat. They have different addr structures and addressing protocols.
I would bet that v6 is not supported
I would bet the same.
and the reason is that v4 is not going away and will likely outlive all of us.
I wouldn't care to speculate on the reason, nor the expectancy.
I would bet that if you write for v4 you will not have any issues.
Well, I'm wanting to provide full functionality. Maybe communicate with IoT things, etc.
v6 is usually something handled by the ISP and should not enter into consideration for your projects.
I appreciate your concerns for my delicate sensibilities. Truth is, I've done TCP programming in assembly language on a '286, Winsock on Win95 and up to 7 (went to Linux), in C, Python, and Gambas in Linux. Early in my career I was a network administrator then I shifted into application development, mostly web based database driven towards the end.
I do understand that you want to learn and experiment but you may not be able to for this.
Not through Gambas Socket it seems. Actually, I'm more in "git 'er done" mode but I want to do it properly form the foundation. I've written a shared library for the job, it is almost complete. The Gambas program allocates a bunch of space, called a "Tube", as an integer array. This is the memory space for the library, and managed by the library. The library itself does not allocate memory so should be multi-thread safe. The Tube is the first argument in every call.

Here is the Gambas interface definition:

Library "/tmp/R/libGambasIPv6"

'---- Life cycle

Extern IPv6_PrepareTube(ArgTube As Integer[], ArgTubeSize As Integer, ArgLaneCount As Integer, RetMessageZ As String)
Extern IPv6_WrapupTube(ArgTube As Integer[])

'---- Information about

Extern IPv6_GetIp(ArgTube As Integer[], ArgLaneIndex As Integer, RetIpAddress As String) As Integer

'---- Listen

Extern IPv6_ListenOn(ArgTube As Integer[], ArgPort As Integer, RetMessageZ As String) As Integer
Extern IPv6_ListenOff(ArgTube As Integer[], ArgLaneIndex As Integer)

'---- Call

Extern IPv6_CallTo(ArgHost As String, ArgPort As Integer) As Integer

'---- Event loop or timer event handler strobing call

Extern IPv6_Strobe(ArgTube As Integer[], ArgWaitMillisec As Integer, RetMessageZ As String) As Integer

'---- Receive data

Extern IPv6_GetReadySize(ArgTube As Integer[], ArgLaneIndex As Integer) As Integer
Extern IPv6_FetchData(ArgTube As Integer[], ArgLaneIndex As Integer, ArgSize As Integer, RetData As String) As Integer

'---- Send data

Extern IPv6_Transmit(ArgTube As Integer[], ArgLaneIndex As Integer, ArgLength As Integer, ArgData As String, RetMessageZ As String) As Integer

'---- Hang up

Extern IPv6_HangUp(ArgTube As Integer[], ArgLaneIndex As Integer)




You should also be able to call it from Pyton, R, FORTRAN, and clearly C.

Here is a wrapper function to make it friendly to other Gambas code:
'=============================================================================
Public Sub TransmitString(ArgLaneIndex As Integer, ArgString As String) As String

        Dim theMessageZ As String = Space(1000) & Chr(0)
        Dim theLength As Integer = Len(ArgString)

        Iv6_Transmit(MyTube, ArgLaneIndex, theLength, ArgString, theMessageZ)

        Dim z As Integer = InStr(theMessageZ, Chr(0))
        
        Return Left(theMessageZ, z - 1)

End
'=============================================================================

I am curious about the project and what it does and the reason for its existence. I might have some ideas for you.
I'm developing an operating environment which aims to be easy to use through a verbal interface. Hence, I am currently testing by logging in with telnet, which I can now do from any machine on my local network using ipv4 or ipv6. Each connection gets its own handler object. I'd rather not say more until I have a near complete working rendition of what I have in mind, then I would welcome ideas.

What I would like help with, and would partially satisfy your curiosity, is testing and code scrutiny of my shared library. It isn't fool proof, nor intended to be, it's meant to be fast and lean.

Anybody who wants to be an alpha tester on my library please email me at cedron a.t. protonmail d.o.t. com. I will be posting it in the Showcase forum at some point, with a simple Gambas driver program.
.... and carry a big stick!
Post Reply