[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Python Programming

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 7
Thread images: 2

File: osh shit waddup.jpg (76KB, 500x733px) Image search: [Google]
osh shit waddup.jpg
76KB, 500x733px
Hey guys I'm new to the /g/ board because I mostly use /b/ but I do enjoy doing amateur beginner programming. At the moment I'm trying to create a socket messenger in python. Do you guys think it's worth it to continue using python and also what could I do to improve it.

*Client:
import socket

TCP_IP = input("Server I.P? ")
TCP_PORT = int(input("Server Port? "))
NAME = input("Your alias? ")
BUFFER_SIZE = 1024

print("[+] Starting Client...")
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print("[+] Connecting To " + str(TCP_IP) + "...")
sock.connect((TCP_IP, TCP_PORT))
while True:
Message = input(NAME + "? ")
sock.send(("(n>)" + NAME + "(<n)" + Message).encode())
data = sock.recv(BUFFER_SIZE).decode()
Incoming = data[(data.index('(<n)') + 4)::]
Alias = data[4:(data.index('(<n)'))]
print(Alias + ": " + str(Incoming))

sock.close()

Server:
import socket

TCP_PORT = int(input("Server Port? "))
NAME = input("Your alias? ")
TCP_IP = 'I'm Not Retarded'
BUFFER_SIZE = 1024

print("[+] Starting Server...")
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print("[+] Binding The Port...")
s.bind((socket.gethostname(), TCP_PORT))
print("[+] Listening On Port...")
s.listen(5)

print("[+] Accepting Connections...")
conn, addr = s.accept()
print("Connection Address: " + str(addr))
while True:
data = conn.recv(BUFFER_SIZE).decode()
if not data: break
Incoming = data[((data).index('(<n)') + 4)::]
Alias = data[4:(data.index('(<n)'))]
print(Alias + ": " + Incoming)
Message = input(NAME + "? ")
conn.send(("(n>)" + NAME + "(<n)" + Message).encode())

conn.close()
>>
Python """"""""programming""""""""
>>
File: ramen.jpg (37KB, 480x507px) Image search: [Google]
ramen.jpg
37KB, 480x507px
>>54864058
Yeah I know I'm very beginner.
>>
>>54864082
That's some kind of rape, or at least sexual battery.
>>
>>54864031
Pastebin.
>>
>>54864031
please op tell me about dat boi
>>
OP you may want to go here instead: http://codereview.stackexchange.com/

Go ahead and continue using Python. You're just learning to program anyway, don't get caught up on whether a different language would be more efficient. Of course you should be doing it in Haskell but you might as well finish what you started! :-)
Thread posts: 7
Thread images: 2


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

If you need a post removed click on it's [Report] button and follow the instruction.
If you like this website please support us by donating with Bitcoin at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties. Posts and uploaded images are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that website. If you need information about a Poster - contact 4chan. This project is not affiliated in any way with 4chan.