[S]imple [N]etwork [C]onnection win and lin 32/64-bit.

Post your FreeBASIC source, examples, tips and tricks here. Please don’t post code without including an explanation.
Post Reply
praetor
Posts: 8
Joined: Nov 16, 2022 3:50

Re: [S]imple [N]etwork [C]onnection win and lin 32/64-bit.

Post by praetor »

I hate to be a PITA, but what do we need to do to get this working? Your library is by far the easiest way of doing networking in FreeBASIC, and I don't really want to reinvent the wheel.

I've tried cracking at it myself, but while I'm a seasoned C programmer, FreeBASIC is new to me and fixing this is a little outside my pay grade. The documentation for FreeBASIC compiler warnings is, well, just not there. So I really have no starting point to fixing this.

Ideas? It's a quick fix. The 4th setsockopt needs to be changed to something. I don't know what that something should be, but I bet you do! :D

--AE
D.J.Peters wrote: Nov 18, 2022 23:08 show me the declaration of "setsockopt" in your include file please
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: [S]imple [N]etwork [C]onnection win and lin 32/64-bit.

Post by srvaldez »

the function declaration for setsockopt in Windows is in win/winsock2.bi, don't know where it is in Linux but the correction needed is probably the same

Code: Select all

declare function setsockopt(byval s as SOCKET, byval level as long, byval optname as long, byval optval as const zstring ptr, byval optlen as long) as long

the 4th argument is byval optval as const zstring ptr
so try and change cptr(const any ptr,@tmp) to cptr(const zstring ptr,@tmp)

the ???sock2.bi may be wrong declaring it as zstring ptr, it probably should be any ptr
praetor
Posts: 8
Joined: Nov 16, 2022 3:50

Re: [S]imple [N]etwork [C]onnection win and lin 32/64-bit.

Post by praetor »

I wonder if there have been changes to sock.bi that broke SNC. I'm sorta busy atm playing with my HP-UX machine, but I'll look at it at bedtime :D
bfg
Posts: 9
Joined: Feb 02, 2008 0:45

Re: [S]imple [N]etwork [C]onnection win and lin 32/64-bit.

Post by bfg »

Code: Select all

root@PC008782:~/fbc# egrep -r -i 'declare function setsockopt' *
inc/win/winsock2.bi:declare function setsockopt(byval s as SOCKET, byval level as long, byval optname as long, byval optval as const zstring ptr, byval optlen as long) as long
inc/win/winsock.bi:declare function setsockopt(byval s as SOCKET, byval level as long, byval optname as long, byval optval as const zstring ptr, byval optlen as long) as long
inc/crt/sys/socket.bi:declare function setsockopt (byval __fd as long, byval __level as long, byval __optname as long, byval __optval as any ptr, byval __optlen as socklen_t) as long
Win use 'zstring' while Linux 'any'
srvaldez wrote: Nov 21, 2022 23:24 the function declaration for setsockopt in Windows is in win/winsock2.bi, don't know where it is in Linux but the correction needed is probably the same

Code: Select all

declare function setsockopt(byval s as SOCKET, byval level as long, byval optname as long, byval optval as const zstring ptr, byval optlen as long) as long

the 4th argument is byval optval as const zstring ptr
so try and change cptr(const any ptr,@tmp) to cptr(const zstring ptr,@tmp)

the ???sock2.bi may be wrong declaring it as zstring ptr, it probably should be any ptr
bfg
Posts: 9
Joined: Feb 02, 2008 0:45

Re: [S]imple [N]etwork [C]onnection win and lin 32/64-bit.

Post by bfg »

Now it works (linux and win)
I've changed

Code: Select all

cptr(const any ptr,@tmp)
with

Code: Select all

cast(any ptr, @tmp)
in line 151 and 158 of snc.bi
praetor
Posts: 8
Joined: Nov 16, 2022 3:50

Re: [S]imple [N]etwork [C]onnection win and lin 32/64-bit.

Post by praetor »

Oh that is very nice! Thank you!!! :D
bfg wrote: Nov 30, 2022 10:56 Now it works (linux and win)
I've changed

Code: Select all

cptr(const any ptr,@tmp)
with

Code: Select all

cast(any ptr, @tmp)
in line 151 and 158 of snc.bi
Post Reply