Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Networking and Web Programming
»
Connect to another aplication via TCP/UDP
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Cannot see unit text - ed...
by
lorenzo
[
Today
at 04:05:13 am]
kick mellstroy VS mellstr...
by
MichaelKam
[
Today
at 02:20:12 am]
AdvancedHTTPServer: A Go-...
by
egsuh
[
Today
at 01:44:33 am]
Perlin Noise Map With BGR...
by
Boleeman
[
Today
at 01:31:57 am]
Apakah Tokopedia Punya WA...
by
Xibition
[
Today
at 01:18:59 am]
Berapa WhatsApp Tokopedia...
by
Xibition
[
Today
at 01:18:36 am]
WhatsApp Tokopedia
by
Xibition
[
Today
at 01:16:59 am]
Berapa kah Nomor WA Tokop...
by
Xibition
[
Today
at 01:16:27 am]
Berapa kah wa Tokopedia
by
Xibition
[
Today
at 01:15:58 am]
Apakah Tokopedia memiliki...
by
Xibition
[
Today
at 01:15:28 am]
Berapa Nomor WA Tokopedia...
by
Xibition
[
Today
at 01:14:35 am]
Nomor WA Tokopedia
by
Xibition
[
Today
at 01:13:33 am]
What's wrong with my appl...
by
VisualLab
[
Today
at 01:04:16 am]
ThemeServices.OnThemeChan...
by
440bx
[
Today
at 12:16:35 am]
[Windows] UTF8 encoding w...
by
bstewart
[
Today
at 12:08:42 am]
Default, Manual Initializ...
by
PascalDragon
[January 20, 2026, 11:03:21 pm]
Cross Compile for Dos on ...
by
PascalDragon
[January 20, 2026, 10:54:36 pm]
Feature announcement: Fun...
by
PascalDragon
[January 20, 2026, 09:50:39 pm]
Access violation during d...
by
PascalDragon
[January 20, 2026, 09:49:09 pm]
IStringList...
by
PascalDragon
[January 20, 2026, 09:35:54 pm]
Lazreport. Sorting.
by
PascalDragon
[January 20, 2026, 09:34:15 pm]
Strings in Free Pascal: I...
by
PascalDragon
[January 20, 2026, 09:33:09 pm]
Developing FreePascal on ...
by
HKPhysicist
[January 20, 2026, 08:59:53 pm]
Anti "churning" in solita...
by
andersonscinfo
[January 20, 2026, 08:37:14 pm]
[Solved] Exception in TFi...
by
d.oertel
[January 20, 2026, 06:18:05 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Connect to another aplication via TCP/UDP (Read 6425 times)
M[a]nny
Full Member
Posts: 130
Dreamer
Connect to another aplication via TCP/UDP
«
on:
July 21, 2011, 11:20:38 am »
Hello!
I'd like to make application which is able to connect via TCP or UDP to another one. I'm not sure how to do this but i can make it in PHP. The application is Counter-Strike 2D dedicated server. Look at this.
This function execute command. It doesn't return anything.
Code: PHP
[Select]
[+]
[-]
function
send_command
(
$ip
,
$port
,
$rcon
,
$command
)
{
$fp
=
@
fsockopen
(
"udp://"
.
$ip
,
$port
,
$errno
,
$errstr
)
;
if
(
$fp
)
{
$request
=
chr
(
1
)
.
chr
(
0
)
.
chr
(
242
)
.
chr
(
strlen
(
$rcon
)
)
.
$rcon
.
pack
(
"S"
,
strlen
(
$command
)
)
.
$command
;
fwrite
(
$fp
,
$request
)
;
}
}
But this one returns some value (for example list of players etc..).
Code: PHP
[Select]
[+]
[-]
function
send_command_rtn
(
$ip
,
$port
,
$rcon
,
$command
)
{
$fp
=
@
fsockopen
(
"udp://"
.
$ip
,
$port
,
$errno
,
$errstr
)
;
if
(
$fp
)
{
$request
=
chr
(
1
)
.
chr
(
0
)
.
chr
(
242
)
.
chr
(
strlen
(
$rcon
)
)
.
$rcon
.
pack
(
"S"
,
strlen
(
$command
)
)
.
$command
;
fwrite
(
$fp
,
$request
)
;
$ausgabe
=
fread
(
$fp
,
1000
)
;
return
$ausgabe
;
}
}
What should i do to make this in Lazarus? Any ideas would be really appreciated!
Logged
Bad news: Time flies.
Good news: You are the pilot.
Don't try to be perfect, just be unique.
WalterK
New Member
Posts: 48
Re: Connect to another aplication via TCP/UDP
«
Reply #1 on:
July 21, 2011, 03:57:43 pm »
I'm not sure if this is what you're looking for, but there are two small example programs in the rtl documentation under the Connect and fpAccept entries; search for sockcli.pp and socksvr.pp. The rtl pdf is here:
ftp://ftp.freepascal.org/pub/fpc/docs-pdf/rtl.pdf
Logged
Leledumbo
Hero Member
Posts: 8835
Programming + Glam Metal + Tae Kwon Do = Me
Re: Connect to another aplication via TCP/UDP
«
Reply #2 on:
July 31, 2011, 09:23:51 am »
FPC has basic units for this with sockets unit. However, it's much easier to use 3rd party libraries like synapse or lnet. For games, it's better to use lnet because it has full asynchronous connection support.
Logged
Follow this if you want me to answer:
http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F
http://pascalgeek.blogspot.com
https://bitbucket.org/leledumbo
https://github.com/leledumbo
Code first, think later - Natural programmer B)
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
Networking and Web Programming
»
Connect to another aplication via TCP/UDP
TinyPortal
© 2005-2018