Pastes:104607  Views:2164643 

Languages:

   ASP
   C#
   C++
   HTML
   Java
   PHP
   VB.NET
   Visual Basic 6

more languages available...


Looking to freelance?


Warning: file_get_contents(http://www.getafreelancer.com/affiliates/itsdan/6f.txt) [function.file-get-contents]: failed to open stream: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? in /home/nmp/public_html/support/googlereferrals.php on line 21
( bids)

Source: GetAFreelancer.com


C# 3D Engine

 

 

 

 

 

 

Here's the requested code from the pastebin:

Wrap Lines   Use Line Numbers
#
# Written by astigmatik
# This is for Jython2.2 RC2 and to show a possible bug when
#  sending to a socket that has been closed/disconnected.
#
 
import socket, threading
 
class SimpleServer(threading.Thread):
 
  def __init__(self):
     print "Server opened"
 
  def run(self):
     serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     serversocket.bind(('localhost', 6667))
     serversocket.listen(1)
     print "Server listening"
     while 1:
        (clientsocket, address) = serversocket.accept()
        print "Server has accepted client"
        break
     clientsocket.close()
     serversocket.close()
     print "Server has closed all sockets"
 
class SimpleClient:
 
  def __init__(self):
     print "Client opened"
 
  def connect(self):
     print "Client connecting"
     s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     s.connect(('localhost', 6667))
     self.sockname = s
     print 'Client will send data to socket after 5 seconds'
     t = threading.Timer(5, self.sockwrite)
     t.start()
 
  def sockwrite(self):
     print 'Client trying to send data'
     self.sendtry(self.sockname, 1)
     self.sendtry(self.sockname, 2)
     print "Done"
 
  def sendtry(self, s, n):
     print "Client attempting to send data. Try no. %s" % n
     try:
        s.send('Hello')
     except socket.error:
        print "Socket error at try no. %s" % n
        s.close()
        print "Client closed from try no. %s" % n
 
def openclient():
  c = SimpleClient()
  c.connect()
 
def main():
  t = threading.Timer(10, openclient)
  t.start()
  server = SimpleServer()
  server.run()
 
if __name__ == '__main__':
  main()
Syntax Highlighting:  



Copyright 2007 - NoMorePasting.com