Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8013

Other programming languages • Re: Basic on Raspberry

$
0
0
PROC_initsockets must be called (once) before any other functions in the SOCKLIB library are accessed; by default it allows up to 16 sockets to be opened simultaneously. If this is insufficient pass the required maximum number of sockets as a parameter, for example:

Code:

PROC_initsockets(100)
In code already specifies the number of connections in a variable MAX_CONNECT. So the example is incorrect. After all, other people will face a similar problem if they decide to increase the number of connections and think that it is a bug.
OK. I found the line PROC_initsockets and replaced it on PROC_initsockets(10000).
The connection speed was slow - 10 connections per second.

I tried to rework the code but it didn't work!

Code:

      DEF FNreceived(s{})      LOCAL N%, reply$, buff%      IF s.socket% = 0 THEN = FALSE      N% = FN_readsocket(s.socket%, PTR(buff%), 4)      IF N% = 0 THEN = FALSE      IF N% > 0 THEN        buff% = buff% + 1000        FN_writesocket(s.socket%, PTR(buff%), 4)      ELSE        PRINT s.viewport$ TAB(s.xcaret%, s.ycaret%);        PRINT "Client closed connection."        PROC_closesocket(s.socket%)        s.socket% = 0      ENDIF        = TRUE
Server error when connecting.
bbc.jpg
Where is the error, in which line of code? Why doesn't BBC BASIC report this?

When I was writing a server in PureBasic, I didn't succeed right away and there were errors, but the IDE told me where and why they occurred. One of the errors I made.
purebasic.jpg
I clicked on the function ReceiveNetworkData and pressed the F1 button on the keyboard. Offline documentation opened (PureBasic.chm) with a description of the function ReceiveNetworkData where I found the answer to what caused the error.
PureBasic_Doc.jpg
It's written in the documentation.
*MemoryBuffer The address of the data to send.
I passed a variable to a function, but the function needs the memory address of that variable.
The offline help has a built-in search. I did a word search memory address and several pages were found, among which was a page Pointers and memory access where did I learn that the address in the memory of a variable can be obtained using the symbol @.
I added it to the beginning of the variable name and the error is gone.

Unfortunately BBC BASIC did not give a hint where the error is and why, and I do not know how to find it and fix it.

Statistics: Posted by Vasian — Sat Mar 29, 2025 2:11 pm



Viewing all articles
Browse latest Browse all 8013

Trending Articles