CodeOnBy - In Between Bytes
  • Home
  • Programming
    • JavaScript
    • Python
  • System
    • Cross-platform
    • Linux
    • macOS
    • Windows
  • Gear
  • About Me
Home
Programming
    JavaScript
    Python
System
    Cross-platform
    Linux
    macOS
    Windows
Gear
About Me
CodeOnBy - In Between Bytes
  • Home
  • Programming
    • JavaScript
    • Python
  • System
    • Cross-platform
    • Linux
    • macOS
    • Windows
  • Gear
  • About Me
Browsing Tag
threading
Cross-platform Programming Python System

Python Control Server – Multiple Clients (5 of 8)

January 2, 2020 3 Comments

[ Part 1 – Part 2 – Part 3 – Part 4 – Part 5 – Part 6 – Part 7 – Part 8 ]

We’re off to part five of our little Python control server.

I had been postponing this, but its time we implement multiple clients!

I knew we had to do this right and that it would most likely bloat the scripts as well, so it would also require breaking it down into specific modules.

So yeah, that’s what we’re doing, lets get into it!

But before that, let me give you guys some context into the code…

Modular Programming

Many times when working on a project, as it begins to expand and get into a few hundred lines of code we need to start breaking it up into modules.

For our project, so far, it seems most of the functionality is divided between server configuration and data encryption.

I figure, just for the sake of development and teaching proper methods to keep working in a program without feeling like its a labyrinth, we’ll go ahead and separate our code into a few modules.

Continue reading
Reading time: 2 min
Share:
Written by: codeboss
Cross-platform Linux macOS Programming Python System Windows

Python Chat Server (4 of 7)

December 14, 2019 No Comments

[ Part 1 (Overview) – Part 2 – Part 3 – Part 4 – Part 5 – Part 6 – Part 7 ]

Welcome to my blog’s first tutorial series!

Check out the video for details on the code!

Ayyyyoooo guys! What’s good?

Continuing from my last post, its time to implement the server thread.

A lot of pieces are already in place to handle the server threads, so we should be able to get it done without too much hassle.

There are some minor code changes in the server script which I will only be covering in the video above, so if you’re only following the blog make sure to download the code at the end of the post and compare the changes.

Let’s write some codes!

Server Handler Code

# Server handler
# --------------------------------------------
# This function will listen for connections as daemons
# and keep connected in background.
def ServerHandler(serverIP, serverPort, clientIP):
	sh = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	sh.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
	sh.bind((serverIP, serverPort))
	sh.listen(1)	# Listen for 1 client, each server = 1 client
	
z,b = sh.accept()
	if (z):
		print "\n[" + GetTime() + "] Connection from " + str(b)
		while True:
			msg = Receive(z)
			if len(str(msg)): print "\n[" + GetTime() + "] " + msg

There isn’t much to the server handler. Basically we fire up a socket using the supplied arguments serverIP and serverPort – this port is the one supplied by the AllocAddress() function we created in the previous part (will basically add +1 to the same port of the main server).

Continue reading
Reading time: 3 min
Share:
Written by: codeboss

Recent Posts

  • Python for Data Recovery
  • Data Recovery using Hex Editor
  • File Transfer in Python 3
  • Intro to SQL Injection (Lab #1)
  • Apache, MySQL & PHP Setup (Win/Linux) for SQL Injection Labs

Recent Comments

  • Brian on Brute-Force VeraCrypt Encryption
  • zhiftyDK on ARP Spoofing with Scapy
  • Alex on Python for Data Recovery
  • john on Data Recovery using Hex Editor
  • Someone1611 on Bind Shell in Python 3

About me

My name is Felipe! I’m a programmer from NY.

Blogs about coding, operating systems, network and security.

Hosting

© 2020 Copyright CodeOnBy // All rights reserved
In Between Bytes