So while our code gets complicated we don't have any problems compartmentalizing other goes.
So the first thing you need to do is you need to create a new directory.
And I'm going to call it core.
So this school will campaign on the functionality of this program domain.
Finally just be use to communicate with the do the very basic things and all the functionality will
be defined inside the board.
So inside the code when defining the new package and then using this as hand and connection.
So this package will help us in handling our connection for example communicating with the victims etc..
Similarly when views are defined the same type of logic in the victim machine as well.
So once you have that we can use this code to create better features for example.
I'm sending that public sector so now in the Hamdan connection I'm going to create a new file and I'm
going to call it establishing the connection that something in this connection
so once we have this package I'm going to create two new functions here.
So I'm going to call this function as connect with the victim.
So the functionality of this function will be that it will take two elements.
The first element will be IP address which should be of type String and then there will be the board
which will also be of type String and then they can do it and do things the first one this connection
should be after a dot com.
And then in case of an added to it it doesn't add a know the first thing we need to do is that if we
go ahead we know that we have to define our address in this fight.
So I'm going to just copy it and paste it here.
So now we have a local address.
The next thing you also need to do is to create this connection time to copy paste here
and then I'm going to post it here.
So now we.
What we are essentially doing is we are organizing normal code to make it more do we do.
And also to see what's happening behind the scenes.
So I'm just going to copy all of it here.
Copy and paste it here.
So now we have everything set up.
There's just a few things you need to know.
So instead of printing error here I'm just going to return the edit here the connection and
similarly if everything goes well I'm going to remove this and just fix that in connection.
Similarly if the collection is successful I'm just going to get done it
if we haven't already defined the time types here we don't need to write it again here.
So now you have a function that can't connect to the victim which dates in an IP address and the port
number and then into tons of connected object.
If we have a proper connection so let's go to the main function.
Okay.
And now what we need to do is we need to get rid of everything here
okay.
Let's do one more thing.
So we have removed everything from the main function except the IP address the board and the connection
variable.
So now we are going to use this and connect with the function uh to get the connection back.
So I'm going to write connection because to connect with the victim
connect to the victim and then I'm going to give my IP address in port.
So as you can see that this much more clear than the previously and so we simply have a connection which
handles all the internal communication and at the end if there is no other returns a successful connection.
Otherwise return some error.
Now we can print out that ad here if there is not equal to men.
We can just print out a lot of freedom and then whatever the error is
okay.
The next thing we need to do is we need to defer our connection.
So we close the connection properly if everything goes wrong or something.
So this DFS statement will help us in closing our connection at the end of this at the end when the
program goes out of scope.
Q What else.
And then we will simply use this connection object to point out the success and a successful election
statement.
Much is that Mitch
and then I'm going to a connection to a more diverse staff stream.
So now you've simplified this set of whatever you can afford.
So we put all the functional here in this package called handle convention and no item in function looks
much more likely that in the next lecture we will do the same process with our victim.