Sha256: 6ad3cef914ff45bf7210f48f0500fd9e1dff9bf3e73da6c1e932c28c1b64cdfa

Contents?: true

Size: 1.14 KB

Versions: 25

Compression:

Stored size: 1.14 KB

Contents

#!/usr/bin/env ruby

$:.unshift(File.join(File.dirname(__FILE__), '..', '..'))

require 'test/unit'
require 'rex/socket/tcp_server'

class Rex::Socket::TcpServer::UnitTest < Test::Unit::TestCase

	def test_tcp_server
		serv_port = 65433
		serv = Rex::Socket.create_tcp_server(
			'LocalPort' => serv_port)
		ccli = nil

		begin
			assert_kind_of(Rex::Socket::TcpServer, serv, "valid TcpServer")
			assert_kind_of(Rex::IO::StreamServer, serv, "valid StreamServer")

			# Connect to the server
			assert_nothing_raised {
				ccli = Rex::Socket.create_tcp(
					'PeerHost' => '127.0.0.1',
					'PeerPort' => serv_port)
			}
			assert_kind_of(Rex::Socket::Tcp, ccli, "valid client client Tcp")

			# Accept the client connection
			scli = serv.accept
			assert_kind_of(Rex::Socket::Tcp, scli, "valid server client Tcp")

			assert_equal(2, scli.put("Yo"), "scli: put Yo")
			assert_equal("Yo", ccli.get(), "ccli: get Yo")
			assert(scli.methods.include?('<<'), "no << operator")
			assert(scli.methods.include?('>>'), "no >> operator")
			assert(scli.methods.include?('has_read_data?'), "no has_read_data?")
			
		ensure
			ccli.close if (ccli)
			serv.close
		end
	end

end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
librex-0.0.65 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.63 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.54 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.53 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.52 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.51 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.50 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.49 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.48 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.47 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.46 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.44 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.43 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.42 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.41 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.40 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.39 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.38 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.37 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.36 lib/rex/socket/tcp_server.rb.ut.rb