Recent

Author Topic: can i make server?  (Read 73130 times)

shs

  • Sr. Member
  • ****
  • Posts: 310
Re: can i make server?
« Reply #180 on: October 27, 2017, 12:55:02 pm »
if the gamer doesn't need to communicate i won't need a "common" server?

rvk

  • Hero Member
  • *****
  • Posts: 6693
Re: can i make server?
« Reply #181 on: October 27, 2017, 01:51:25 pm »
if the gamer doesn't need to communicate i won't need a "common" server?
Why do you call the game "online" then?

I asked you what you exactly meant with "online game".

shs

  • Sr. Member
  • ****
  • Posts: 310
Re: can i make server?
« Reply #182 on: October 27, 2017, 02:05:26 pm »
i want to make application game and i want people to connect to it and play

rvk

  • Hero Member
  • *****
  • Posts: 6693
Re: can i make server?
« Reply #183 on: October 27, 2017, 02:14:37 pm »
i want to make application game and i want people to connect to it and play
Bingo... connect to what ???

Where do you "host" the game?

shs

  • Sr. Member
  • ****
  • Posts: 310
Re: can i make server?
« Reply #184 on: October 27, 2017, 02:34:39 pm »
in the application?

rvk

  • Hero Member
  • *****
  • Posts: 6693
Re: can i make server?
« Reply #185 on: October 27, 2017, 02:41:32 pm »
in the application?
And where is your application running?
On a hoster somewhere or on your own computer/server?

If it's on your own computer/server you would need to open up a port again for the clients to be able to reach it.

shs

  • Sr. Member
  • ****
  • Posts: 310
Re: can i make server?
« Reply #186 on: October 28, 2017, 02:10:14 am »
oh okay but if i want to use the local network i don't have to right?

jamie

  • Hero Member
  • *****
  • Posts: 6826
Re: can i make server?
« Reply #187 on: October 28, 2017, 03:13:30 am »
While thinking about it, you may want to use UDP packets. They are faster but can suffer
from lost data.
  If the data you plan on  exchanging is things like player moves then you can create your own
 error checking for the packets.

 Doing it the TCP way will cause the network to do hand shaking and that slows things down
for quick responses and not needed if you can evaluate the data you receive as a whole to
determine if it's a useable block of data.
The only true wisdom is knowing you know nothing

rvk

  • Hero Member
  • *****
  • Posts: 6693
Re: can i make server?
« Reply #188 on: October 28, 2017, 07:49:37 am »
oh okay but if i want to use the local network i don't have to right?
Yes. You should understand that by now since you already made a message program that worked locally.

shs

  • Sr. Member
  • ****
  • Posts: 310
Re: can i make server?
« Reply #189 on: October 28, 2017, 02:41:57 pm »
but how can i make a game with that?
for example in the server game, if i'm wanna make the shape move and if the client connects to the server, the client can move his shape. how can it read the movement?
for messaging they had recv and sendstring

rvk

  • Hero Member
  • *****
  • Posts: 6693
Re: can i make server?
« Reply #190 on: November 16, 2017, 11:34:24 am »
In your Button1Click in the server you have a repeat until false.
This is an never ending loop.
You never break out in that loop.

So when you click the close button, the program is still executing that loop.

You need to create a break-mechanisme to break out of that loop.

(You could set a boolean WeNeedToTerminate to true in FormClose and change the repeat to "repeat until WeNeedToTerminate".)

shs

  • Sr. Member
  • ****
  • Posts: 310
Re: can i make server?
« Reply #191 on: November 16, 2017, 12:48:13 pm »
is it better to use timer than the repeat method?

rvk

  • Hero Member
  • *****
  • Posts: 6693
Re: can i make server?
« Reply #192 on: November 16, 2017, 12:50:37 pm »
You could use a second timer for the ListenerSocket to listen to incoming connections, yes.

Better would be threads but that's fat more complex.
(try the Timer2 first)

shs

  • Sr. Member
  • ****
  • Posts: 310
Re: can i make server?
« Reply #193 on: November 18, 2017, 01:27:16 am »
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Timer2Timer(Sender: TObject);
  2. begin
  3.     if ListenerSocket.canread(100) then
  4.     begin
  5.       edit3.Enabled := True;
  6.       button2.Enabled := True;
  7.       SetLength(Connections, Length(Connections) + 1);
  8.       Connections[high(Connections)].Sock := TTCPBlockSocket.Create;
  9.       Connections[high(Connections)].Sock.Socket := ListenerSocket.Accept;
  10.       Timer1.Enabled := True;
  11.       //memo1.Lines.add('Client ' + IntToStr(length(connections)) + ' is connected');
  12.       if length(connections) = 1 then
  13.       begin
  14.         memo1.Lines.add(FormatDateTime('DDDD, dd MMMM YYYY HH:MM:SS', Now));
  15.         memo1.Lines.add(
  16.           '------------------------------------------------------------------------');
  17.         memo1.Lines.add('Say Something');
  18.       end;
  19.     end;
  20. end;    
yes it works
i made this 'disconnect' but i get sigsegv error message when i click that button

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button3Click(Sender: TObject);
  2. begin
  3.   timer1.enabled:=false;
  4.   button3.enabled:=false;
  5.   button1.enabled:=true;
  6.   ListenerSocket.closesocket;
  7.   listenersocket.free;
  8. end;      

rvk

  • Hero Member
  • *****
  • Posts: 6693
Re: can i make server?
« Reply #194 on: November 18, 2017, 01:35:49 am »
Also disable Timer2 in Button3Click because if you free the ListenerSocket you can't use that anymore in Timer2 until you click button1 again (when it is recreated).

 

TinyPortal © 2005-2018