Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8594777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:16:36+00:00 2026-06-12T00:16:36+00:00

Keeps on getting index out of range error when I run this code how

  • 0

Keeps on getting index out of range error when I run this code how do i solve this? The data contains a few values that would be passed down to the valueList through a server and i would like to use a part of those values in the data. For example , int(valueList[8]) contains the x coordinate of the ball. how do I solve this issue?

import os,sys
import pygame
import socket
import time
from multiprocessing import Process, Value
from ctypes import c_bool

Host = '59.191.193.45'
Port = 5555

def updatePosition(valueList, update_valueList, quit_flag):
    while not quit_flag.value:
        print 'Ball x', int(valueList[8])
        print 'Ball y', int(valueList[9])
        update_valueList = valueList[:]
    print 'Closing child update process'

def activateRobot(update_valueList, quit_flag): 
    while not quit_flag.value:
        print 'Ball x', int(valueList[8])
        print 'Ball y', int(valueList[9])
        print 'turn to'
        print 'move to', int(valueList[8])
        print 'move to', int(valueList[9])
    print 'Closing child activate robot process'

client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect((Host,Port))

valueList = []
update_valueList = []
quit_flag = Value(c_bool,False)

update = Process(target = updatePosition, args=(valueList, update_valueList,quit_flag))
activate = Process(target = activateRobot, args=(update_valueList,quit_flag))

update.start()
activate.start()

while True:
    client.sendall("loc\n")
    data = client.recv(8192)
    if not data:
        print 'network connection close by client'
        break
    valueList = data.split()

print 'All done, closing child process'
update.join()
activate,join()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:16:38+00:00Added an answer on June 12, 2026 at 12:16 am

    This

    data = client.recv(8192)
    

    receives up to 8192 bytes. You are probably getting partial lines. The line doesn’t have to be longer than 8192 bytes for this to happen. You just get to read what has arrived over the network so far which might not be whole lines.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting an error that states my String index is out of range
This is my short function that keeps getting Those columns are out of bounds
I keep getting this error: line 4, in timesTwo IndexError: list index out of
I keep getting an Notice: Undefined index: did error with this query, and I'm
I keep getting this error in Matlab: Attempted to access r(0,0); index must be
I keep getting this error on my views. I can't work it out as
In this code I keep getting an error, I know its how I'm saving
While developing with Firebug I keep getting this error. pages[x].css(z-index,x) is not a function
How do I fix this error, pos_coordinates contains a list of values and the
My unit test keeps getting the following error: System.InvalidOperationException: The Connection is not open.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.