Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Linux: terminal output
#1
Hi,
Another obscene question boys Smile 

I got a few remote orange pi boards running qb64pe main programs, some c programs as SPI and I2C 'drivers' of sorts feeding data back and forth through pipes, to qb64pe.
Theres a networking aspect to this whole setup, and I realized I can't get the computer name into qb64 automatically.

Does anyone know if theres a way to get it before I try to change the system terminal output to a pipe and use qb64 to interface the system terminal? Huh
Reply
#2
well pardon myself,

it looks like theres a file, '/etc/hostname' that has what I was looking for.

I'll leave this and not erase in case some other dumb person like myself needs it
Reply
#3
I figured I'd put my code, as irrelevant or silly some think it is, in case someone else is fighting...
(use whatever for ports, I just picked a random one)

This is the client end:




'dummy program to connect to server
cname$ = "bench-a" ' replace string with server computer name, 'bench-a' was mine
keeptrying:
desip$ = "TCP/IP:50064:" + cname$
Print "Trying to connect to "; desip$; "..."
ch = _OpenClient(desip$)
_Delay 1
If ch <> 0 Then GoTo answer
GoTo keeptrying

answer:
Print "Connected, file number:"; ch

And this is the server waiting for incoming connection:


'just a dummy program to act as a server

' get this computers name from hostname file
Open "/etc/hostname" For Input As #1
Input #1, hostname$
Close #1
Print "This computer to connect to: "; hostname$

serverport$ = "TCP/IP:50064"
servername& = _OpenHost(serverport$)

hangout:
_Delay 1
If InKey$ > "" Then End
Print "Waiting..."
n& = _OpenConnection(servername&)
If n& = 0 Then GoTo hangout
Print "Connected-";
Print _ConnectionAddress(n&)
Print "filenumber:"; n&
Reply
#4
As an alternative using Linux libc function gethostname...

Code: (Select All)

DECLARE LIBRARY
    FUNCTION gethostname% (name AS STRING, BYVAL len AS _UNSIGNED LONG)
END DECLARE

DIM hostname AS STRING * 1024
IF gethostname(hostname, 1024) = 0 THEN
    PRINT hostname
END IF
Reply
#5
(05-31-2025, 04:11 AM)Parkland Wrote: Hi,
Another obscene question boys Smile 

I got a few remote orange pi boards running qb64pe main programs, some c programs as SPI and I2C 'drivers' of sorts feeding data back and forth through pipes, to qb64pe.
Theres a networking aspect to this whole setup, and I realized I can't get the computer name into qb64 automatically.

Does anyone know if theres a way to get it before I try to change the system terminal output to a pipe and use qb64 to interface the system terminal? Huh
If I understand correctly what you're describing, if both the 'driver' program and the QB64PE main program are on the same machine you can just use `localhost` or `127.0.0.1` to connect back to the same machine without needing to know the name of it.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Make windows .exe using Linux version? Circlotron 7 495 01-15-2026, 09:42 PM
Last Post: ahenry3068
  QB64 odd behavior when Windows Terminal is set to default terminal app hanness 13 1,441 10-03-2025, 12:52 AM
Last Post: bert22306
  Linux Lubuntu INKEY$ issue TempodiBasic 7 634 09-09-2025, 02:53 PM
Last Post: hsiangch_ong
  Linux - file dialogue boxes... atl068 7 908 08-05-2025, 07:21 PM
Last Post: hsiangch_ong
  System Linux Chris 9 1,202 07-12-2025, 08:51 PM
Last Post: Chris

Forum Jump:


Users browsing this thread: