• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 06:14
CEST 12:14
KST 19:14
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Code S Season 1 - RO8 Preview6[ASL21] Ro8 Preview Pt2: Progenitors8Code S Season 1 - RO12 Group A: Rogue, Percival, Solar, Zoun13[ASL21] Ro8 Preview Pt1: Inheritors16[ASL21] Ro16 Preview Pt2: All Star10
Community News
Maestros of The Game 2 announcement and schedule !7Weekly Cups (April 27-May 4): Clem takes triple0RSL Revival: Season 5 - Qualifiers and Main Event12Code S Season 1 (2026) - RO12 Results12026 GSL Season 1 Qualifiers25
StarCraft 2
General
Code S Season 1 - RO8 Preview Behind the Blue - Team Liquid History Book Weekly Cups (April 27-May 4): Clem takes triple Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool Code S Season 1 (2026) - RO12 Results
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament Sea Duckling Open (Global, Bronze-Diamond) Maestros of The Game 2 announcement and schedule ! GSL Code S Season 1 (2026) RSL Revival: Season 5 - Qualifiers and Main Event
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players
External Content
Mutation # 524 Death and Taxes The PondCast: SC2 News & Results Mutation # 523 Firewall Mutation # 522 Flip My Base
Brood War
General
Quality of life changes in BW that you will like ? Why there arent any 256x256 pro maps? BGH Auto Balance -> http://bghmmr.eu/ RepMastered™: replay sharing and analyzer site Tulbo's ASL S21 Ro8 Post-Review
Tourneys
[ASL21] Ro8 Day 4 [ASL21] Ro8 Day 3 Escore Tournament StarCraft Season 2 [Megathread] Daily Proleagues
Strategy
Simple Questions, Simple Answers Fighting Spirit mining rates What's the deal with APM & what's its true value Any training maps people recommend?
Other Games
General Games
Path of Exile Stormgate/Frost Giant Megathread Nintendo Switch Thread Daigo vs Menard Best of 10 OutLive 25 (RTS Game)
Dota 2
The Story of Wings Gaming
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
US Politics Mega-thread The Letting Off Steam Thread European Politico-economics QA Mega-thread UK Politics Mega-thread Canadian Politics Mega-thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [Req][Books] Good Fantasy/SciFi books
Sports
2024 - 2026 Football Thread McBoner: A hockey love story Formula 1 Discussion
World Cup 2022
Tech Support
streaming software Strange computer issues (software) [G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
How EEG Data Can Predict Gam…
TrAiDoS
ramps on octagon
StaticNine
Funny Nicknames
LUCKY_NOOB
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1421 users

The Big Programming Thread - Page 518

Forum Index > General Forum
Post a Reply
Prev 1 516 517 518 519 520 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Millitron
Profile Blog Joined August 2010
United States2611 Posts
September 13 2014 19:52 GMT
#10341
On September 14 2014 04:39 FFGenerations wrote:
yo, thanks for the reply. it can sound different from the titles alone but i spoilered the actual syllabuses which, whilst sometimes say stuff like "learn about ethics of mobile phone application" also say a lot of words that i have never heard in my life lol.

i have written some initial thoughts on each optional unit here:

+ Show Spoiler +

APPLIED COMPUTER GRAPHICS AND VISION

this sounds pretty good. the 1.5hr exam assessment sounds daunting (putting your entire university grade on the line in 1 exam paper sounds pretty dumb to me).....?

DATA WAREHOUSING AND MINING

i done some phpmyadmin and sql in my college course. it sounds like itd be a good module to solidify this but also sounds a bit dull. i should look up the terms used here like Data clustering techniques to see what they actually mean....

this unit is recommended by the letterwriter who said the teacher is helpful and its easy since we've done a lot of it before.

DISTRIBUTED AND MOBILE SYSTEMS

this sounds good and bad. the bad side is ive never had any interest in mobile gaming and still have a £10 phone thats biggest feature is it can store 100 messages and 10 notes.

the other "bad" side is half the coursework is writing about mobile phone ethics and design which is also a dull as shit assignment but i would ace it.

the "good" side is 50% is coursework at developing your own application which sounds brilliant although i might have to buy a phone.

DISTRIBUTED SYSTEMS AND PARALLEL PROGRAMMING

this is core to the Computer Science degree which means its pretty gritty right?

i have absolutely zero fucking clue what any of the words here mean.

on the very very plus side, its all coursework including staged coursework which means you "do and document" which i love doing....

FUZZY LOGIC - THEORY AND APPLICATIONS

no idea what this is... will look it all up

it is also closed book exam which sounds like a big risk.

NEURAL NETWORKS AND GENETIC ALORGITHMS

again no idea what this is all about. sounds hard.

on one hand i seem to enjoy challenging structural problems, on the other hand i have literally 0 math.

exam here too which is a risk.

PROFESSIONAL AND ACADEMIC RESEARCH DEVELOPMENT

ezmode , letterwriter said "everyone got over 70%"

downside: boring and pointless?

WEB RESEARCH

this is core for BSC (HONS) web technologies
it sounds like it is 50% writing crap but 50% probably looking at web technologies which is not that interesting to me
the assessment style looks pretty easy ....



also posted this at my TL blog http://www.teamliquid.net/blogs/466957-software-engineering-university-choices


obviously im going to google these syllabuses a bit since i have no idea, for example, what a fuzzy logic is


ps: i got my vbs macro structure working with the arrays, i put it to a test and it ran for 60 minutes scrolling through the website links while i waited for it to need to go "up" an extra level to see if that functionality continued to work, when after 60 fucking minutes the website in question went down for maintenance

i dont have the IQ to figure out how to "preset" my code to put it into a testmode that doesnt take 60+ minutes.... it has to run down each link until it hits a particular standard stop word and then moves on from there.... i cant give it an "easier" stop word to look for since the stop word is only a certain place on the website.

perhaps i could add a counter variable and say when counter=3 then isStopword=1... yeah that might work....?????!!!

Parallel programming is a fancy way to say multi-threading usually. It could also mean cloud computing, in the sense that Folding@Home uses the term. i.e. using a bunch of complete systems to work simultaneously on one problem.

Distributed systems are computers that do not exist in one physical location. The CPU might be on one machine, the ROM might be somewhere else. The idea is that the resources you commonly take for granted aren't so easy to access.
Who called in the fleet?
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2014-09-13 20:26:42
September 13 2014 20:25 GMT
#10342
thanks for the reply

did you guys pick any of the units ive got as options?

ill look up what all these terms mean so i can give each unit a rating of interest out of 100 in order to narrow them down...

im so fucking tired from staring at code, i can play dota or HS for 10 hours straight and not be this worn out

IM SO FUCKING TIRED but its like i WANT to be awake so i can keep doing this , compared to when i play dota or HS all day i just feel sick of it lol
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
phar
Profile Joined August 2011
United States1080 Posts
September 13 2014 23:23 GMT
#10343
A distributed systems course is almost certainly talking more about folding@home style than multi-threading. Could be very interesting.

Honestly I would advocate picking the classes with the better professor.
Who after all is today speaking about the destruction of the Armenians?
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2014-09-14 05:32:45
September 14 2014 05:23 GMT
#10344
None of the classes sound that great in my opinion. Descriptions aren't that helpful (esp. these ones). It's much better to talk to other students who have taken it and ask for their opinions.

I would only consider the first five,

DISTRIBUTED SYSTEMS AND PARALLEL PROGRAMMING
>
APPLIED COMPUTER GRAPHICS AND VISION == FUZZY LOGIC - THEORY AND APPLICATIONS == DISTRIBUTED AND MOBILE SYSTEMS
>
DATA WAREHOUSING AND MINING

in order of what I think sounds least lame and more useful/applicable to CS/SE.

Speak with the academic advisor for the program at the university you're going to. Infinitely better resources than the internet. If not, I would just choose the ones that sound the most interesting to you.
There is no one like you in the universe.
obesechicken13
Profile Blog Joined July 2008
United States10467 Posts
September 14 2014 06:48 GMT
#10345
On September 14 2014 08:23 phar wrote:
A distributed systems course is almost certainly talking more about folding@home style than multi-threading. Could be very interesting.

Honestly I would advocate picking the classes with the better professor.

How do you know which professor is good?

I tend to pick easier ones now but used to pick by interest.
I think in our modern age technology has evolved to become more addictive. The things that don't give us pleasure aren't used as much. Work was never meant to be fun, but doing it makes us happier in the long run.
nunez
Profile Blog Joined February 2011
Norway4003 Posts
Last Edited: 2014-09-14 22:26:21
September 14 2014 22:09 GMT
#10346
all my programs are silent prayers to gcc:
take onto you my ungodly syntax, and bring forth the indended semantic.
conspired against by a confederacy of dunces.
bardtown
Profile Joined June 2011
England2313 Posts
September 15 2014 00:20 GMT
#10347
Making my first 'useful' python program - a chat room, basically. Unfortunately when I try to connect to the server (which I'm running in one thread if the user chooses to host a server, with another client thread) it says that the connection is being actively refused. Looking on google, this does not seem to be a problem with the code but perhaps with my router or something similar. Anybody have ideas, or want to try to run the code (which is scruffy and incomplete but should run)? It's run from the command lane, give the extra argument -h to host a server.

+ Show Spoiler +
import sys, socket, threading, select
from time import sleep

killcode = 0

def main (argv):
def serverFlow(): #Server function/loop, to be run as a background thread if -h argument is given
global killcode
servsock = socket.socket( #Create a server socket
socket.AF_INET, socket.SOCK_STREAM)
servsock.bind((socket.gethostname(), 18505))
servsock.listen(5) #Listen for connections, and queue up to 5 connect requests
while True:
c, addr = servsock.accept() #This is blocking... Maybe make a thread out of it? Thread needs to count connections and only accept them while there are less than 8 connections
if killcode == 1:
break
serverThread = threading.Thread(target=serverFlow, args=()) #Define the server thread

def clientFlow(ip = 0): #Client function/loop
global killcode
un = ''
while len(un) > 12 or len(un) < 2: #Get a username of the right length
un = input('Enter desired username (2-12 characters): ')
if serverThread.isAlive() == True: #Check if server is being hosted locally, if so set i.p. to localhost
ip = '127.0.0.1'
print('Connecting to', ip + '...')
sleep(0.1) #Short pause to ensure server has time to start...
clientsock = socket.socket(
socket.AF_INET, socket.SOCK_STREAM)
try:
clientsock.connect((ip, 18505))
except socket.error:
print('Cannot connect.')
sys.exit()
#connect... if successful go to loop, which sends and receives input. Thread for user input -> send, and another for listening?
while True:
x = input('>') #possible put this in a prompt() function which requests input, deletes the line when entered, then sends said input over the socket.
if x == '/kill':
killcode = 1
break
clientThread = threading.Thread(target=clientFlow, args=()) #Define the client thread. Required if -h argument is given for multithreading with server

exception1 = 'Usage: \'shrike -h\' to host, or \'shrike -c ip\' to connect to a host.'
#Error message for incorrect syntax

"""END OF MAIN DEFINITIONS. BEGIN MAIN EXECUTION"""

if len(sys.argv) < 2:
print(exception1)
sys.exit()

elif sys.argv[1] == '-h':
print('Welcome to Shrike. Creating server and listening for connections...')
serverThread.start() #Start server thread
clientThread.start() #Start client thread running simultaneously

elif sys.argv[1] == '-c' and len(sys.argv)==3: #If the connect argument is given, check the correct number of arguments have been given
ip = sys.argv[2]
try:
socket.inet_aton(ip) #Check if ip is a valid address
except socket.error:
print(exception1, '\n', ip, 'is not a valid IP address.')
sys.exit()
print('Welcome to Shrike.')
clientFlow(ip)

else:
print(exception1)
sys.exit()

"""END OF COMMAND LINE ARGUMENT PARSING"""

main(sys.argv)
berated-
Profile Blog Joined February 2007
United States1134 Posts
Last Edited: 2014-09-15 11:04:36
September 15 2014 11:01 GMT
#10348
On September 15 2014 09:20 bardtown wrote:
Making my first 'useful' python program - a chat room, basically. Unfortunately when I try to connect to the server (which I'm running in one thread if the user chooses to host a server, with another client thread) it says that the connection is being actively refused. Looking on google, this does not seem to be a problem with the code but perhaps with my router or something similar. Anybody have ideas, or want to try to run the code (which is scruffy and incomplete but should run)? It's run from the command lane, give the extra argument -h to host a server.

+ Show Spoiler +
import sys, socket, threading, select
from time import sleep

killcode = 0

def main (argv):
def serverFlow(): #Server function/loop, to be run as a background thread if -h argument is given
global killcode
servsock = socket.socket( #Create a server socket
socket.AF_INET, socket.SOCK_STREAM)
servsock.bind((socket.gethostname(), 18505))
servsock.listen(5) #Listen for connections, and queue up to 5 connect requests
while True:
c, addr = servsock.accept() #This is blocking... Maybe make a thread out of it? Thread needs to count connections and only accept them while there are less than 8 connections
if killcode == 1:
break
serverThread = threading.Thread(target=serverFlow, args=()) #Define the server thread

def clientFlow(ip = 0): #Client function/loop
global killcode
un = ''
while len(un) > 12 or len(un) < 2: #Get a username of the right length
un = input('Enter desired username (2-12 characters): ')
if serverThread.isAlive() == True: #Check if server is being hosted locally, if so set i.p. to localhost
ip = '127.0.0.1'
print('Connecting to', ip + '...')
sleep(0.1) #Short pause to ensure server has time to start...
clientsock = socket.socket(
socket.AF_INET, socket.SOCK_STREAM)
try:
clientsock.connect((ip, 18505))
except socket.error:
print('Cannot connect.')
sys.exit()
#connect... if successful go to loop, which sends and receives input. Thread for user input -> send, and another for listening?
while True:
x = input('>') #possible put this in a prompt() function which requests input, deletes the line when entered, then sends said input over the socket.
if x == '/kill':
killcode = 1
break
clientThread = threading.Thread(target=clientFlow, args=()) #Define the client thread. Required if -h argument is given for multithreading with server

exception1 = 'Usage: \'shrike -h\' to host, or \'shrike -c ip\' to connect to a host.'
#Error message for incorrect syntax

"""END OF MAIN DEFINITIONS. BEGIN MAIN EXECUTION"""

if len(sys.argv) < 2:
print(exception1)
sys.exit()

elif sys.argv[1] == '-h':
print('Welcome to Shrike. Creating server and listening for connections...')
serverThread.start() #Start server thread
clientThread.start() #Start client thread running simultaneously

elif sys.argv[1] == '-c' and len(sys.argv)==3: #If the connect argument is given, check the correct number of arguments have been given
ip = sys.argv[2]
try:
socket.inet_aton(ip) #Check if ip is a valid address
except socket.error:
print(exception1, '\n', ip, 'is not a valid IP address.')
sys.exit()
print('Welcome to Shrike.')
clientFlow(ip)

else:
print(exception1)
sys.exit()

"""END OF COMMAND LINE ARGUMENT PARSING"""

main(sys.argv)


So soon to be starting with the "there is nothing wrong with the code". You'll make a great dev.

There is nothing wrong with your router if you are trying to stay entirely local on your machine, which it looks like you are because you are trying to connect to 127.0.0.1.

The problem is that in the server thread you are binding to the client hostname, not 127.0.0.1 . So, you can choose to bind to 127.0.0.1, and your example would work.. but then you wouldn't be accepting anywhere other than on 127.0.01. So, bind to "0.0.0.0". Disclaimer: I'm not a networking expert, I don't know if there are dangers to do doing so in a real production environment. However, I know that it works.

Also, as unsolicited advice, you should look into argparse with python. It will make life easier as you keep writing more scripts.
Manit0u
Profile Blog Joined August 2004
Poland17743 Posts
Last Edited: 2014-09-15 11:33:57
September 15 2014 11:19 GMT
#10349
On September 15 2014 09:20 bardtown wrote:
Making my first 'useful' python program - a chat room, basically. Unfortunately when I try to connect to the server (which I'm running in one thread if the user chooses to host a server, with another client thread) it says that the connection is being actively refused. Looking on google, this does not seem to be a problem with the code but perhaps with my router or something similar. Anybody have ideas, or want to try to run the code (which is scruffy and incomplete but should run)? It's run from the command lane, give the extra argument -h to host a server.

+ Show Spoiler +
import sys, socket, threading, select
from time import sleep

killcode = 0

def main (argv):
def serverFlow(): #Server function/loop, to be run as a background thread if -h argument is given
global killcode
servsock = socket.socket( #Create a server socket
socket.AF_INET, socket.SOCK_STREAM)
servsock.bind((socket.gethostname(), 18505))
servsock.listen(5) #Listen for connections, and queue up to 5 connect requests
while True:
c, addr = servsock.accept() #This is blocking... Maybe make a thread out of it? Thread needs to count connections and only accept them while there are less than 8 connections
if killcode == 1:
break
serverThread = threading.Thread(target=serverFlow, args=()) #Define the server thread

def clientFlow(ip = 0): #Client function/loop
global killcode
un = ''
while len(un) > 12 or len(un) < 2: #Get a username of the right length
un = input('Enter desired username (2-12 characters): ')
if serverThread.isAlive() == True: #Check if server is being hosted locally, if so set i.p. to localhost
ip = '127.0.0.1'
print('Connecting to', ip + '...')
sleep(0.1) #Short pause to ensure server has time to start...
clientsock = socket.socket(
socket.AF_INET, socket.SOCK_STREAM)
try:
clientsock.connect((ip, 18505))
except socket.error:
print('Cannot connect.')
sys.exit()
#connect... if successful go to loop, which sends and receives input. Thread for user input -> send, and another for listening?
while True:
x = input('>') #possible put this in a prompt() function which requests input, deletes the line when entered, then sends said input over the socket.
if x == '/kill':
killcode = 1
break
clientThread = threading.Thread(target=clientFlow, args=()) #Define the client thread. Required if -h argument is given for multithreading with server

exception1 = 'Usage: \'shrike -h\' to host, or \'shrike -c ip\' to connect to a host.'
#Error message for incorrect syntax

"""END OF MAIN DEFINITIONS. BEGIN MAIN EXECUTION"""

if len(sys.argv) < 2:
print(exception1)
sys.exit()

elif sys.argv[1] == '-h':
print('Welcome to Shrike. Creating server and listening for connections...')
serverThread.start() #Start server thread
clientThread.start() #Start client thread running simultaneously

elif sys.argv[1] == '-c' and len(sys.argv)==3: #If the connect argument is given, check the correct number of arguments have been given
ip = sys.argv[2]
try:
socket.inet_aton(ip) #Check if ip is a valid address
except socket.error:
print(exception1, '\n', ip, 'is not a valid IP address.')
sys.exit()
print('Welcome to Shrike.')
clientFlow(ip)

else:
print(exception1)
sys.exit()

"""END OF COMMAND LINE ARGUMENT PARSING"""

main(sys.argv)


Not related to your problem, but something you might consider nonetheless: You might want to allow users to specify arguments in different order than just the one hard-set by yourself. Most Linux users are pretty accustomed to mixing their command arguments as they please.


if '-c' in sys.argv
ip_idx = sys.argv.index('-c') + 1

try:
ip = sys.argv[ip_idx]
except socket.error:
print(exception1, '\n', 'wrong argument at position', ip_idx)
sys.exit()


It's way more flexible this way since you can add/remove arguments from your program without having to worry about them being bound to specific order. You also don't run the risk of errors on trying to access non-existent indexes in the array.
Time is precious. Waste it wisely.
berated-
Profile Blog Joined February 2007
United States1134 Posts
September 15 2014 11:33 GMT
#10350
On September 15 2014 20:19 Manit0u wrote:
Show nested quote +
On September 15 2014 09:20 bardtown wrote:
Making my first 'useful' python program - a chat room, basically. Unfortunately when I try to connect to the server (which I'm running in one thread if the user chooses to host a server, with another client thread) it says that the connection is being actively refused. Looking on google, this does not seem to be a problem with the code but perhaps with my router or something similar. Anybody have ideas, or want to try to run the code (which is scruffy and incomplete but should run)? It's run from the command lane, give the extra argument -h to host a server.

+ Show Spoiler +
import sys, socket, threading, select
from time import sleep

killcode = 0

def main (argv):
def serverFlow(): #Server function/loop, to be run as a background thread if -h argument is given
global killcode
servsock = socket.socket( #Create a server socket
socket.AF_INET, socket.SOCK_STREAM)
servsock.bind((socket.gethostname(), 18505))
servsock.listen(5) #Listen for connections, and queue up to 5 connect requests
while True:
c, addr = servsock.accept() #This is blocking... Maybe make a thread out of it? Thread needs to count connections and only accept them while there are less than 8 connections
if killcode == 1:
break
serverThread = threading.Thread(target=serverFlow, args=()) #Define the server thread

def clientFlow(ip = 0): #Client function/loop
global killcode
un = ''
while len(un) > 12 or len(un) < 2: #Get a username of the right length
un = input('Enter desired username (2-12 characters): ')
if serverThread.isAlive() == True: #Check if server is being hosted locally, if so set i.p. to localhost
ip = '127.0.0.1'
print('Connecting to', ip + '...')
sleep(0.1) #Short pause to ensure server has time to start...
clientsock = socket.socket(
socket.AF_INET, socket.SOCK_STREAM)
try:
clientsock.connect((ip, 18505))
except socket.error:
print('Cannot connect.')
sys.exit()
#connect... if successful go to loop, which sends and receives input. Thread for user input -> send, and another for listening?
while True:
x = input('>') #possible put this in a prompt() function which requests input, deletes the line when entered, then sends said input over the socket.
if x == '/kill':
killcode = 1
break
clientThread = threading.Thread(target=clientFlow, args=()) #Define the client thread. Required if -h argument is given for multithreading with server

exception1 = 'Usage: \'shrike -h\' to host, or \'shrike -c ip\' to connect to a host.'
#Error message for incorrect syntax

"""END OF MAIN DEFINITIONS. BEGIN MAIN EXECUTION"""

if len(sys.argv) < 2:
print(exception1)
sys.exit()

elif sys.argv[1] == '-h':
print('Welcome to Shrike. Creating server and listening for connections...')
serverThread.start() #Start server thread
clientThread.start() #Start client thread running simultaneously

elif sys.argv[1] == '-c' and len(sys.argv)==3: #If the connect argument is given, check the correct number of arguments have been given
ip = sys.argv[2]
try:
socket.inet_aton(ip) #Check if ip is a valid address
except socket.error:
print(exception1, '\n', ip, 'is not a valid IP address.')
sys.exit()
print('Welcome to Shrike.')
clientFlow(ip)

else:
print(exception1)
sys.exit()

"""END OF COMMAND LINE ARGUMENT PARSING"""

main(sys.argv)


Not related to your problem, but something you might consider nonetheless: You might want to allow users to specify arguments in different order than just the one hard-set by yourself. Most Linux users are pretty accustomed to mixing their command arguments as they please.


if '-c' in sys.argv
ip_idx = sys.argv.index('-c') + 1

try:
ip = sys.argv[ip_idx]
except socket.error:
print(exception1, '\n', 'no valid IP address given.')
sys.exit()


It's way more flexible this way since you can add/remove arguments from your program without having to worry about them being bound to specific order. You also don't run the risk of errors on trying to access non-existent indexes in the array.


That's why I suggested argparse. Only thing better than being flexible is not writing it yourself!
Millitron
Profile Blog Joined August 2010
United States2611 Posts
September 15 2014 16:00 GMT
#10351
On September 14 2014 05:25 FFGenerations wrote:
thanks for the reply

did you guys pick any of the units ive got as options?

ill look up what all these terms mean so i can give each unit a rating of interest out of 100 in order to narrow them down...

im so fucking tired from staring at code, i can play dota or HS for 10 hours straight and not be this worn out

IM SO FUCKING TIRED but its like i WANT to be awake so i can keep doing this , compared to when i play dota or HS all day i just feel sick of it lol


Neural networks and fuzzy logic sound the most interesting to me. When you say you have 0 math, you should still be ok as long as your formal logic skills are up to par. CS doesn't really use calculus or things like that much, at least in my experience.
Who called in the fleet?
phar
Profile Joined August 2011
United States1080 Posts
Last Edited: 2014-09-15 16:02:12
September 15 2014 16:01 GMT
#10352
On September 14 2014 15:48 obesechicken13 wrote:
Show nested quote +
On September 14 2014 08:23 phar wrote:
A distributed systems course is almost certainly talking more about folding@home style than multi-threading. Could be very interesting.

Honestly I would advocate picking the classes with the better professor.

How do you know which professor is good?

I tend to pick easier ones now but used to pick by interest.

Ask around. It is typically very obvious to past students whether or not the professor is actually good at teaching undergrads and is enthusiastic, or is just doing it because they are forced to, and really would prefer to get back to their phd students.

Occasionally you can find out info on some website, but just asking people should suffice.
Who after all is today speaking about the destruction of the Armenians?
bardtown
Profile Joined June 2011
England2313 Posts
September 15 2014 17:19 GMT
#10353
On September 15 2014 20:01 berated- wrote:
Show nested quote +
On September 15 2014 09:20 bardtown wrote:
Making my first 'useful' python program - a chat room, basically. Unfortunately when I try to connect to the server (which I'm running in one thread if the user chooses to host a server, with another client thread) it says that the connection is being actively refused. Looking on google, this does not seem to be a problem with the code but perhaps with my router or something similar. Anybody have ideas, or want to try to run the code (which is scruffy and incomplete but should run)? It's run from the command lane, give the extra argument -h to host a server.

+ Show Spoiler +
import sys, socket, threading, select
from time import sleep

killcode = 0

def main (argv):
def serverFlow(): #Server function/loop, to be run as a background thread if -h argument is given
global killcode
servsock = socket.socket( #Create a server socket
socket.AF_INET, socket.SOCK_STREAM)
servsock.bind((socket.gethostname(), 18505))
servsock.listen(5) #Listen for connections, and queue up to 5 connect requests
while True:
c, addr = servsock.accept() #This is blocking... Maybe make a thread out of it? Thread needs to count connections and only accept them while there are less than 8 connections
if killcode == 1:
break
serverThread = threading.Thread(target=serverFlow, args=()) #Define the server thread

def clientFlow(ip = 0): #Client function/loop
global killcode
un = ''
while len(un) > 12 or len(un) < 2: #Get a username of the right length
un = input('Enter desired username (2-12 characters): ')
if serverThread.isAlive() == True: #Check if server is being hosted locally, if so set i.p. to localhost
ip = '127.0.0.1'
print('Connecting to', ip + '...')
sleep(0.1) #Short pause to ensure server has time to start...
clientsock = socket.socket(
socket.AF_INET, socket.SOCK_STREAM)
try:
clientsock.connect((ip, 18505))
except socket.error:
print('Cannot connect.')
sys.exit()
#connect... if successful go to loop, which sends and receives input. Thread for user input -> send, and another for listening?
while True:
x = input('>') #possible put this in a prompt() function which requests input, deletes the line when entered, then sends said input over the socket.
if x == '/kill':
killcode = 1
break
clientThread = threading.Thread(target=clientFlow, args=()) #Define the client thread. Required if -h argument is given for multithreading with server

exception1 = 'Usage: \'shrike -h\' to host, or \'shrike -c ip\' to connect to a host.'
#Error message for incorrect syntax

"""END OF MAIN DEFINITIONS. BEGIN MAIN EXECUTION"""

if len(sys.argv) < 2:
print(exception1)
sys.exit()

elif sys.argv[1] == '-h':
print('Welcome to Shrike. Creating server and listening for connections...')
serverThread.start() #Start server thread
clientThread.start() #Start client thread running simultaneously

elif sys.argv[1] == '-c' and len(sys.argv)==3: #If the connect argument is given, check the correct number of arguments have been given
ip = sys.argv[2]
try:
socket.inet_aton(ip) #Check if ip is a valid address
except socket.error:
print(exception1, '\n', ip, 'is not a valid IP address.')
sys.exit()
print('Welcome to Shrike.')
clientFlow(ip)

else:
print(exception1)
sys.exit()

"""END OF COMMAND LINE ARGUMENT PARSING"""

main(sys.argv)


So soon to be starting with the "there is nothing wrong with the code". You'll make a great dev.

There is nothing wrong with your router if you are trying to stay entirely local on your machine, which it looks like you are because you are trying to connect to 127.0.0.1.

The problem is that in the server thread you are binding to the client hostname, not 127.0.0.1 . So, you can choose to bind to 127.0.0.1, and your example would work.. but then you wouldn't be accepting anywhere other than on 127.0.01. So, bind to "0.0.0.0". Disclaimer: I'm not a networking expert, I don't know if there are dangers to do doing so in a real production environment. However, I know that it works.

Also, as unsolicited advice, you should look into argparse with python. It will make life easier as you keep writing more scripts.


I was too quick to take the word of some answers on stackoverflow, that's true. I have learnt my lesson. I'm guessing at this point that binding to the hostname is only functional on LAN? It didn't occur to me that it could be binding to the PC without binding to an IP address.

Thanks very much, anyway. It feels good to be able to continue with this project.

Thankyou Manit0u, for your advice. I think that is a more elegant way of handling the arguments and I've made a note of it. For this project I'll leave it as it is, so that I can review my patchwork problem solving in future.
Ben...
Profile Joined January 2011
Canada3485 Posts
September 15 2014 17:46 GMT
#10354
On September 16 2014 01:01 phar wrote:
Show nested quote +
On September 14 2014 15:48 obesechicken13 wrote:
On September 14 2014 08:23 phar wrote:
A distributed systems course is almost certainly talking more about folding@home style than multi-threading. Could be very interesting.

Honestly I would advocate picking the classes with the better professor.

How do you know which professor is good?

I tend to pick easier ones now but used to pick by interest.

Ask around. It is typically very obvious to past students whether or not the professor is actually good at teaching undergrads and is enthusiastic, or is just doing it because they are forced to, and really would prefer to get back to their phd students.

Occasionally you can find out info on some website, but just asking people should suffice.

Yup, this is exactly what to do. I chose my image processing/computer vision class specifically because I had the prof that teaches it already and he was amazing. It turns out I really like this type of stuff but I subject matter didn't really matter to me, I just wanted a final year class from a known quantity in terms of professor quality. I can survive basically any subject matter, but if a prof is bad, chances are I will do much worse in the class. Likewise, I have two profs next term that I chose because people said they were amazingly good profs and gave reasonable assignments. Sadly, bad profs are sometimes unavoidable though.
Unfortunately for me, I have two mandatory/semi-mandatory classes (as in, you need this class to do any of the classes I want to do next term. And in turn, if you want to graduate this year) and they both are taught by among the worst professors in the CS department. I swear they save all the awful professors for the last year, because it certainly seems that way. I only have one good prof this term. It's like "if you want this degree, you'll have to make it through this absolute nonsense".
"Cliiiiiiiiiiiiiiiiide" -Tastosis
doyougmailbro
Profile Joined September 2014
8 Posts
Last Edited: 2014-09-15 17:54:35
September 15 2014 17:53 GMT
#10355
I wouldn't brag about the 3-4 year of university education if I were you. Most excellent programmers were self-taught. You do sound lazy and incompetent and I find it funny how you throw your "university education" around like people would respect you more. The fact is that you don't do anything outside of class and you didn't learn any real application in computer science and just going from class to class without much thought. I would rather hire someone with real practical experience than anyone who hasn't done anything practical. Your university education doesn't indicate any level of competence but merely a ticket for me to look at your resume once to determine your capability and most likely as an employer I would test you on specific concepts to see if you actually know anything.

Ben...
Profile Joined January 2011
Canada3485 Posts
September 15 2014 20:55 GMT
#10356
On September 16 2014 02:53 doyougmailbro wrote:
I wouldn't brag about the 3-4 year of university education if I were you. Most excellent programmers were self-taught. You do sound lazy and incompetent and I find it funny how you throw your "university education" around like people would respect you more. The fact is that you don't do anything outside of class and you didn't learn any real application in computer science and just going from class to class without much thought. I would rather hire someone with real practical experience than anyone who hasn't done anything practical. Your university education doesn't indicate any level of competence but merely a ticket for me to look at your resume once to determine your capability and most likely as an employer I would test you on specific concepts to see if you actually know anything.


Why are you trying to start a fights (I saw you do the same thing in another thread too)? It's incredibly obvious. I wasn't throwing my education around in any way. I was discussing choosing university CS courses with other people who are talking about the same thing and in the same situation I am (if they are talking about computer vision courses and things like that, they are probably in the same year I am in, or maybe a year below. Computer Vision/Image Processing is often a senior year course). How dare we discuss CS and programming related stuff in a thread about CS and programming. Choosing courses and professors is an important thing because it can have a huge impact on one's education. If you don't respect university degrees, then that's your prerogative, but that doesn't mean that it is okay for you to be rude and disrespectful to others because of it. There was no need for you to rudely cut into this conversation when you have nothing of worth to contribute except talk down to everyone else involved.

No need to be a jerk. Trying to be all condescending and edgy like this just makes you come off as an unpleasant person trying too hard to make yourself feel/look superior to other people when it's obvious you probably aren't. Most people can see through that shtick fairly easily. You won't make many friends with this level of negativity and this type of attitude. Every single one of your posts so far has been confrontational and condescending like this, and it seems unlikely you will last any significant length of time on TL if your posting stays like this.

And that is all I will say with regards to this. I'll just ignore the personal attacks against my abilities (even though this person obviously knows absolutely nothing of them and is going purely upon poorly crafted assumptions which are almost all incorrect). There's no point addressing them. I'll just let angry people be angry.
"Cliiiiiiiiiiiiiiiiide" -Tastosis
FFGenerations
Profile Blog Joined April 2011
7088 Posts
September 15 2014 21:09 GMT
#10357
what i thought he was talking about me to which i thought "fair enough" LOL
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
ZenithM
Profile Joined February 2011
France15952 Posts
September 15 2014 21:54 GMT
#10358
On September 16 2014 02:53 doyougmailbro wrote:
I wouldn't brag about the 3-4 year of university education if I were you. Most excellent programmers were self-taught. You do sound lazy and incompetent and I find it funny how you throw your "university education" around like people would respect you more. The fact is that you don't do anything outside of class and you didn't learn any real application in computer science and just going from class to class without much thought. I would rather hire someone with real practical experience than anyone who hasn't done anything practical. Your university education doesn't indicate any level of competence but merely a ticket for me to look at your resume once to determine your capability and most likely as an employer I would test you on specific concepts to see if you actually know anything.


Someone sounds bitter.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2014-09-15 22:44:04
September 15 2014 22:43 GMT
#10359
Yo, i blogged an update after today. will post it here for you. cheers for your replies, really helped

quick update, spoke to course coord today and he suggested that 1) i avoid certain modules 2) i definitely take a module 3) i need to learn math before i start the 2nd half of one of the core modules 4) if i find out when module lectures are i can attend some to sample a module 5) although i have to submit my module choices tomorrow i can still change them up to 12 days later

he suggested professional dev module is compulsory , which really is fine by me after considering that i want an easy ride in order to focus on personal projects. (i didnt mention it before but we have a 40 credit core module of personal project. i probably should have mentioned it).

[-] data mining is pretty dry and i done a fair bit of database stuff in college and i dont exactly fall head over heels to do more

[-] computer graphics sounds great but it does sound like something you'd do alongside or following a less specific unit... eg combo mobile graphics with mobile dev unit. it is also half exam

[+] professioanl dev. was basically told to take this if i am direct entry student. probably because its the mega easy one. im fine with this. especially hearing some of your opinions that spending time on personal unique projects is more valuable than having done a class on something specific like fuzzy logic or even more database crap which you can learn on the job.

[-] web research. similar to data mining, i dont find web tech that interesting and i basically have 1 choice to make here

[-] fuzzy logic, genetic alg or parallel prog. quite specific subjects, which brings me to....

[+] distributed systems + mobile systems. yeah this is 2 separate units, first half you look at stuff like cloud tech, which is useful to know about. 2nd half you build a mobile application, which is great imo. no exam assessment.



SO WHAT WILL MY WEEKS CONSIST OF?

1) Advanced software engineering - models, design and management. assessment: 15 minute presentation on subject matter (40%) and 2 hour writing exam (60%).

2) Reliable and secure systems - various including network security, xacml, formal modelling. 100% staggered coursework.

3) Distributed systems, mobile systems. Cloud/etc technology coursework 50%. Mobile ap coursework 50%.

4) Professional development. 100% written coursework

5) Personal project & report (assessment highly weighted on report).

6) Math (i think i start with matrices, matrix multiplication, and then move onto this module content + Show Spoiler +
1 Sets (describing sets by properties, operations on sets, subsets, power sets, counting finite sets, the Cartesian product of sets), binary relations (equivalence). Functions (basic terminology, composition of functions, inverse functions, recursive functions, partial and total functions).
2 Basic proof techniques (the concept of proofs, mathematical induction, proof by contradiction). Logic (truth tables, introduction to propositional calculus, predicate logic, quantifiers, formal reasoning, logical equivalences, formalising sentences).
3 Introduction to functional programming. How functional programming differs from imperative programming.
4 Basic functional concepts and data types. Functions, guards, pattern matching. Recursive functions. Lists and list processing using recursion.
5 Foundations of functional programming: the lambda calculus. Reasoning about functional programs. Proving properties and correctness of programs using induction.
6 Higher order functions. Function composition, Currying and partial application. Lambda expressions. Processing lists with higher order functions. Lazy evaluation.
7 Input-Output for functional programs: providing user interfaces.
8 Introduction to graph theory (notation and representation of graphs, adjacency matrices). Basic properties of graphs (e.g. connectivity, edge and vertex cuts, Euler theorem) and connections with practical problems.
9 Various kinds of graphs (e.g. trees, bipartite graphs, complete graphs, directed graphs), their properties and applications.
10 Fundamental graph algorithms (e.g. For finding an Eulerian circuit, for solving the minimum spanning tree problem). Application of graph algorithms to practical problems. Using digraphs for solving networks problems (e.g. the maximum flow problem).


7) Gym

8) Join an RPG
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
RoyGBiv_13
Profile Blog Joined August 2010
United States1275 Posts
September 15 2014 23:08 GMT
#10360
On September 15 2014 07:09 nunez wrote:
all my programs are silent prayers to gcc:
take onto you my ungodly syntax, and bring forth the indended semantic.


Compilers are one-file-in-one-file-out programs, how hard could they be? Linkers are the true deity.

+ Show Spoiler +

Our Linker in binary,
+x be thy permissions.
Your ELF, COFF, and PE come,
your allocation be done,
on our binary as it is in yours.
Give us libraries for our executable,
and forgive us our bugs,
as we have forgiven our compiler.
And lead us not into warnings,
but deliver us from errors.
Amen

Take unto Thee, this list of blessed libraries, modules, and symbol tables. Let it be to Your eternal satisfaction that all instances of symbols are singularly defined, and that no COMMONS exist. Amen.
Any sufficiently advanced technology is indistinguishable from magic
Prev 1 516 517 518 519 520 1032 Next
Please log in or register to reply.
Live Events Refresh
RSL Revival
10:00
Season 5: Group D
Cure vs Zoun
Clem vs Lambo
Tasteless627
IntoTheiNu 386
Ryung 222
Rex35
IndyStarCraft 14
LiquipediaDiscussion
Sparkling Tuna Cup
10:00
Weekly #131 (TLMC 22 Edition)
MiniZergUA vs ExostrikerLIVE!
Classic vs TBD
CranKy Ducklings25
CranKy Ducklings SOOP7
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Tasteless 627
Ryung 222
Rex 35
IndyStarCraft 14
StarCraft: Brood War
BeSt 457
Hyuk 293
ZerO 249
sorry 81
Shine 80
Mind 77
Pusan 63
Movie 62
JulyZerg 58
Nal_rA 51
[ Show more ]
Backho 40
Last 33
zelot 32
910 31
Shinee 22
yabsab 20
Noble 7
Liquid`Ret 2
Dota 2
Gorgc3607
monkeys_forever167
XcaliburYe95
Other Games
gofns14276
singsing1465
B2W.Neo391
KnowMe117
DeMusliM20
ZerO(Twitch)18
MindelVK10
Organizations
Counter-Strike
PGL31871
Other Games
gamesdonequick2451
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 17 non-featured ]
StarCraft 2
• Berry_CruncH278
• LUISG 29
• Adnapsc2 15
• IndyKCrew
• sooper7s
• Migwel
• LaughNgamezSOOP
• Kozan
• intothetv
• AfreecaTV YouTube
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Nemesis3476
• Jankos1262
• TFBlade1175
Other Games
• WagamamaTV180
Upcoming Events
WardiTV Invitational
1h 47m
ByuN vs Rogue
Solar vs Ryung
Zoun vs Percival
Cure vs SHIN
BSL
8h 47m
Dewalt vs DragOn
Aether vs Jimin
GSL
21h 47m
Afreeca Starleague
23h 47m
Soma vs Leta
Wardi Open
1d 1h
Monday Night Weeklies
1d 5h
OSC
1d 13h
CranKy Ducklings
1d 23h
Afreeca Starleague
1d 23h
Light vs Flash
Replay Cast
2 days
[ Show More ]
Replay Cast
3 days
The PondCast
3 days
Replay Cast
4 days
RSL Revival
4 days
Korean StarCraft League
5 days
RSL Revival
5 days
BSL
6 days
GSL
6 days
Cure vs TBD
TBD vs Maru
Liquipedia Results

Completed

Escore Tournament S2: W6
WardiTV TLMC #16
Nations Cup 2026

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
KCM Race Survival 2026 Season 2
Acropolis #4
KK 2v2 League Season 1
BSL 22 Non-Korean Championship
SCTL 2026 Spring
RSL Revival: Season 5
2026 GSL S1
PGL Astana 2026
BLAST Rivals Spring 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2

Upcoming

YSL S3
Escore Tournament S2: W7
Escore Tournament S2: W8
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
Maestros of the Game 2
2026 GSL S2
BLAST Bounty Summer 2026: Closed Qualifier
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.