Hello and welcome to the Golden and Programming Languages course in the previous session.
We could implement Ron client function and send data.
And in this session, we want to go to implement strong server function.
So go to the round server function.
First, the master server to be ready to lease on the port, and this port is the same port that we
defined in the same data function to do this.
We will call the lease and function from the net package.
This function, and now on the local network, address and access to parameters as network and address
and return to values as listener and it'll first define to variable like leasing round.
It'll be nice and a
little column equals invoke, lease and function from the Nith package.
Net Dot Nissan said TCP as network parameter
for teasing networks if the host in the antis promise from his or on a specified IP address.
Listen, Lee sends an all available, unique system in a cast IP address of the local system and now
CET address as address parameter for the example 127.0.0.1 and support 885.
Check their status
and set, if not all the roof locked up.
Fattore
listener at all.
In this section, we designed a for loop that the server is always listening to the specified port.
So for this purpose we used from accept function.
So right for
and call him accept function from listener.
This function returns to values as connection and little connection, and a row column equals and coordinates
a function from listener dot accent.
Check Iran's status, you don't fattore and said the message he sent it all.
We are now designing go protein function to see the connection as an input parameter and be able to
read the received data.
We can define function here.
So why go for a defined goal routine gold form
and define a variable like see us connection parameter C.
Net dot com
and said connection important as this as input parameter for function.
First, using D3 for close and connection to.
See that close
lets time to receive data for this purpose, be used from read all function from I or Util package.
Read our function reads from reader until an error or in the fight and returns.
The data is.
Read
this function exit a reader as input parameter and returns to values first in binary as data and sick
in the middle.
Now define two variables.
Data comma column equals calling.
Read readable function from all to package.
I will U.T. and read on function set connection variable as reader parameter connection.
First, check our status.
Not doing that well at all.
And now it's time to realize the values in the data and Putin insider person object.
First, create an object from person, a strong like person.
Color equals Anderson to call
that person now calling on martial function from or packaged to dis realize the data value into person
object.
So we write protocol dot on Marshawn and CIT data and person, as are humans.
And display the person value, FP
person.
Now we can implement the server function.
This function is always listening on the defined port to receive information and en masse on it.
We were able to implement the client and server function sections.
Now it's time to run the program for this purpose.
We used two separate terminals to execute the client and server methods.
To do these, right click on the main go forward and select the Rebond File Explorer.
In the window that opens, hold down the shift key and right click and select the open policy challenge.
Now in new power shifting laws opens for us and do this again.
So another terminal opens for us, reassigned the two open terminals inside the screen so we can see
both at the same time.
OK, now we use this command to run our program once with the seven flag and once we decline for that.
So for the Sierra, we right go wrong.
Main but go.
Yes, I mean and say refuge
and go to client and right go wrong.
Does that mean that go dash?
I mean by client flat and wrong?
Now we see that after running the client, the data is displayed on the server site.
Do this again.
Yes, we can see the person information I.D. One name came and age 25.
So in this photo on his sarcastic to implement a protocol, pather by serializing the data on the client
side and sending it to the server and the server is listening to gets information and receives the serialized
data.
So the serialized data and displays it.
OK.
We have reached the end of this session.
I hope you have taken full advantage of decision until next session.
Goodbye.