News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_Joseman

CPChessNet [developing]

Started by Joseman, 00:36, 03 March 18

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Duke

Quote from: Joseman on 15:59, 19 March 18
if i setup first the client and put it listening for a server and after of this, setup the server, the conexion doesn't work NEVER

what can i doing bad?

Check the status byte. You cannot connect to a server which does not exist so it should time out and give you an error.

Quote
And other question, this is from the start, but never looked back again until the game is nearly finished...

my client/server cpc's create a socket, but i never close the sockets, the first time they choose 01h, if i reset the cpc, they choose 02h and so on...

what is the correct way of closing a socket, and this way the cpc's always use 01h?
When you no longer need the connection (say user exits), you simply close the socket you were given (ie. 1) and it will be available next time.
Also if an error occurs, you should close the socket and re-create it.

Joseman

Thankyou @Duke

to close a socket i understand that this is the code:

exit_close:
            ld    hl,cmdclose
            call    sendcmd           
            ret


but i cant see  where the number of socket to be closed is specified... maybe in the a register?

if i do this code alone (without specifying socket) sometimes it appears to close the open socket but other times it just freeze...

Duke

Quote from: Joseman on 21:29, 19 March 18
but i cant see  where the number of socket to be closed is specified... maybe in the a register?

if i do this code alone (without specifying socket) sometimes it appears to close the open socket but other times it just freeze...

Yes, you need to send the socket number you want to close aswell.


cmdclose: db &03
dw    C_NETCLOSE
clsocket: db &0                <----------- put socket number here


You can also find parameters for all M4 commands here:
http://www.spinpoint.org/cpc/m4info.txt  under "Developer information".

C_NETCLOSE      0x4333      Implemented v1.0.9.   data[0] = socket. 

Joseman

Hi!

Thankyou for the answers!

Quote from: Duke on 22:03, 19 March 18
You can also find parameters for all M4 commands here:
http://www.spinpoint.org/cpc/m4info.txt  under "Developer information".

C_NETCLOSE      0x4333      Implemented v1.0.9.   data[0] = socket. 


Yes yes, i read the documentation but for someone like me starting with M4 and protocols is a little hard to understand some things!

for example C_NETCLOSE is 2 times repeated with different ports, wich can be fine, but it's a little obscure, i didn't know what to use until i saw in your client code that C_NETCLOSE    equ &4333!

and "C_NETCLOSE Implemented v1.0.9.    data[0] = socket"

it took me a little while to understand that data[0] is
cmdclose:        db    &03  <---- data[0]
            dw    C_NETCLOSE

maybe it's just me, but maybe the instructions are a little advanced to people trying to understand whats goin' on with protocols, m4 and client/server applications!  :laugh:


Duke

Quote from: Joseman on 10:09, 20 March 18
it took me a little while to understand that data[0] is
cmdclose:        db    &03  <---- data[0]
            dw    C_NETCLOSE
It's not correct, this is how it works:
cmdclose: db &03           <---- Size of command+data to be sent
dw    C_NETCLOSE         <---- command (size 2)
clsocket: db &0               <---- data[0] (size 1)

Quote
maybe it's just me, but maybe the instructions are a little advanced to people trying to understand whats goin' on with protocols, m4 and client/server applications!  :laugh:
Sorry ;) - Maybe that's why so few used it. I did provide examples, so usage should be self explanatory... oh well.

Joseman

Quote from: Duke on 10:42, 20 March 18
It's not correct, this is how it works:
cmdclose: db &03           <---- Size of command+data to be sent
dw    C_NETCLOSE         <---- command (size 2)
clsocket: db &0               <---- data[0] (size 1)
Sorry ;) - Maybe that's why so few used it. I did provide examples, so usage should be self explanatory... oh well.
sorry, thats is how i understood it!! the first is the size data, yesterday i saw it, today morning... oh well XD

Enviado desde mi GT-N7100 mediante Tapatalk


Joseman

#56
Hi @Duke


if i do this piece of code in my program:

wait_connect:

                        ;wait for ESC to press, if it's pressed then i do the cmdclose command
       
            ld    a,(ix)    ; get socket status  (0 ==IDLE (OK), 1 == connect in progress,
                                        ; 2 == send in progress)
           

                        cp    1 ; connect in progress?
            jr    z,wait_connect
            cp    0
            jr    z,connect_ok
             jp no_connect



I'm waiting for ESC to press to go back to the menu, while the bucle wait_connect is made...

when i hit esc, i go to a sub that performs the cmdclose command and jump to the main menu.

But not always returns to main menu, sometimes it returns, but sometimes is just hangs on the cmdclose command (i know it because i change to red border just after the cmdclose command, and because if i disconnect the M4 from power it goes back to the menu!)

Why is the M4 hanging in the cmdclose (but not always)?

on the no_connect jump i jump back to the cmdconnect command continue to the wait_connect command

can i call the cmdconnect command as many times as i want or there is a limit, or is supossed to call only one time?

Duke

Quote from: Joseman on 15:06, 20 March 18

Why is the M4 hanging in the cmdclose (but not always)?

Do you store the socket number when you open it, so you are sure you are closing the right socket?

Quote
on the no_connect jump i jump back to the cmdconnect command continue to the wait_connect command

can i call the cmdconnect command as many times as i want or there is a limit, or is supossed to call only one time?
You are only supposed to call it one time. Of course if it eventually gives an error code, you can jump to it again, but as long as it returns "connect in progress" (1), you should not send a connect command again.
Just read status byte and check when it is connected (or error occurs).

Joseman

#58
Quote from: Duke on 15:22, 20 March 18
Do you store the socket number when you open it, so you are sure you are closing the right socket?

yes, on the server and on the client, just when you save the socket on (csocket) i save it to another variable (using_socket), when i go to close de socket
i do ld a,(using_socket) ld (cLsocket),a --> cmdclose



QuoteYou are only supposed to call it one time. Of course if it eventually gives an error code, you can jump to it again, but as long as it returns "connect in progress" (1), you should not send a connect command again.
Just read status byte and check when it is connected (or error occurs).

one question:

if i do

; connect to server
           
            ld    hl,cmdconnect
            call    sendcmd
            ld    a,(iy+3)
            cp    255 ;#FF error
            jp    z,error_conectando_server

.error_conectando_server
call 0


if i put an inexistent ip (192.168.0.50) i suposse that the cpc it's going to reboot

BUT it doesnt reboot, it reach the wait_connect bucle!

Duke

Quote from: Joseman on 15:28, 20 March 18
yes, on the server and on the client, just when you save the socket on (csocket) i save it to another variable (using_socket), when i go to close de socket
i do ld a,(using_socket) ld (cLsocket),a --> cmdclose
Also make sure that when you opened the socket, its a valid socket (1 to 4 ).
Quote
if i put an inexistent ip (192.168.0.50) i suposse that the cpc it's going to reboot

BUT it doesnt reboot, it reach the wait_connect bucle!
It will not know at that point, that the IP does not exist.
You will have to check the status byte from the read only address for the corresponding socket.

Joseman

Quote from: Duke on 15:44, 20 March 18
Also make sure that when you opened the socket, its a valid socket (1 to 4 ).

added  check port 1 to 4 to my code (server and client code)! [/quote]

Quote
It will not know at that point, that the IP does not exist.
You will have to check the status byte from the read only address for the corresponding socket.

then the cp #ff, jump z,error

when activates? only when on the other side is another cpchessnet server but for some reason didn't accept the connection?

Duke

Quote from: Joseman on 15:55, 20 March 18
then the cp #ff, jump z,error

when activates? only when on the other side is another cpchessnet server but for some reason didn't accept the connection?
The 0xFF error only occurs, if the socket is out of range (less than 1 or bigger than 4).

Joseman

Quote from: Duke on 16:04, 20 March 18
The 0xFF error only occurs, if the socket is out of range (less than 1 or bigger than 4).

almost i have it...

BUT

sometimes the cmdsocket command retuns '0' socket, if i understand is the local M4 not giving any free socket to the local cpc.

i compare that IF it's 0 then try to do another cmdsocket (without close anyting, i understand that at this point there isnt any conexion to close)

and again the m4 hangs in the cmdsocket :(, why?

sorry for so many questions and thankyou Duke.

Joseman

@Duke

AT LAST, AT LAST IT WORKS!!!!

you can believe it? i was disabling the upper rom in one routine!

then the socket readed was 0, or what the screen had  :laugh:






Duke

Quote from: Joseman on 17:57, 20 March 18
AT LAST, AT LAST IT WORKS!!!!

you can believe it? i was disabling the upper rom in one routine!

Good, 'cause I could not find anywhere the netsocket would return 0 :)

Joseman

CPChessNet 1.0b is reality at last!

*Net code is a lot stable now (connect/listen), not perfect, but very reliable,  there is no code to test if any conection lost occurs (i don't know how the game will perfom on internet)
*screen win/lose added, and the possibility of restart a game (it is tricky to assure that is correct, because of the thousands variables that the game is using, i don't know if there is any variable not initialice between games... time will tell)

very very soon the game on your cpc's to test.

@Duke, i suspect that there is need to open the router port 1234 for cpchessnet server?

Pic:





Duke

Quote from: Joseman on 04:45, 21 March 18
@Duke, i suspect that there is need to open the router port 1234 for cpchessnet server?
Yes, if you used same port as the example it is port 4660 (0x1234). Also on the server you will need to forward the port to your CPC IP.

Joseman

Quote from: Duke on 07:04, 21 March 18
Yes, if you used same port as the example it is port 4660 (0x1234). Also on the server you will need to forward the port to your CPC IP.

Do you think that i should include a port election and not attach the game only to one port?


pic:


Duke

Quote from: Joseman on 18:46, 21 March 18
Do you think that i should include a port election and not attach the game only to one port?
Yes, that would be a good choice.
Play as server/host, enter port (default to something, so you can just press enter).
Cool loading screen !

remax

Nice Game Gear screen simulation  :-X
Brain Radioactivity

Joseman


remax

Quote from: Joseman on 13:45, 22 March 18
game gear?


Having both at home (multiple copies) i can tell you that your last screenshot has far more in common with the screen of a Game Gear than with the screen of a CPC  :D .


To compare, just take a look at the photograph you took a few posts before !


Anyway, i long for playing this game ;)
Brain Radioactivity

Joseman

Quote from: remax on 16:33, 22 March 18

Having both at home (multiple copies) i can tell you that your last screenshot has far more in common with the screen of a Game Gear than with the screen of a CPC  :D .


To compare, just take a look at the photograph you took a few posts before !


Anyway, i long for playing this game ;)


yes, it's the winape screenshot option, nothing like the real hardware

Joseman

#73
Hi

time has come!

Added the port option!

the default port is 6128  ;D

it was complicated for me to add a dec to hex port! i do in the nasty way, if you put 64321 i multiply 6x10000, 4x1000, 3x100,2x10,1x1, add all the result to a variable, then load the variable on a 16bit register (hl) and i do. ld de,#0000 , inc de, dec hl cp #0000, if not repeat bucle. at the end of the bucle, de has the hex por number  :laugh:

You can see the slowness of the routine if you put a high port, for example 60000, it take a while to go to the next screen!

oh, and is not the first time that i'm doing another things and found a bug on things that i thinked that it worked!!

this means that CPChessNET 1.0b has the 100% of possibilites to have bugs... take this on mind .

Here it is!

CPChessNET 1.0b for you.

REMEMBER to open the port 6128 (or whatever you choose) on the server router!!

I think that while CPChessNET is not free of bugs, better not upload it on your webpages or repositories!

Duke

Cool, congrats on the release.  Look forward to try it.

Now someone pm with their IP if they want to play a game over the inet :)

Powered by SMFPacks Menu Editor Mod