Someone who is following the software has seen that I have asked something about pseudo-code some hours ago here if you want to follow the context)
Well, I need to make a pseudo-code in English that will be the basis for implementing this code in Java, C # and C ++, Javascript and other languages ( some already implemented ).
So I ventured to do this pseudo-code, but I do not know if it is correct, can you tell me how to do it to make it more up-to-date and consistent with reality? That's right? What to change?
STRUCTURE TYPECONNECTION
Client
Server
END TYPECONNECTION
VARIABLES
TypeConnection,
NetworkStream,
Writer,
Reader,
Server,
Client,
Ip,
Port
IsStarted
ENDVARIABLES
STRUCTURE SOKETSUPPORT
PROCEDURE CONFIGURE
SWICH TypeConnection
CASE TypeConnection is Server
initialize server with ip and port
start Server
END CASE
CASE TypeConnection is Client
initialize client
END CASE
END SWICH
END CONFIGURE
RETURNS true
END CONFIGURE
PROCEDURE SENDDATA(data)
TRY
IF
SWITCH TypeConnection
CASE TypeConnection is Server
write data in Writer
flushes writer
closes soket
END CASE
CASE TypeConnection is Client
initialize client with ip and port
initialize NetworkStream
initialize Writer
initialize Reader
IF Client is connected
write data in Writer
flushes writer
END IF
END CASE
END SWITCH
END IF
RETURNS IsStarted
END TRY
CATCH
RETURNS false
END CATCH
END SENDDATA
PROCEDURE RECEIVEDATA
TRY
IF IsStarted
SWITCH TypeConnection
CASE TypeConnection is server
Accept socket
initialize NetworkStrem with socket
initialize Reader with NetworkStrem
RETURNS Reader's reading
END CASE
CASE TypeConnection is client
RETURNS Reader's reading
close client
END CASE
END SWITCH
END IF
END TRY
CATCH
RETURNS Exception message
END CATCH
END RECEIVEDATA
END SOKETSUPPORT