Sha256: fef9d9ee4629e8c034c424c8a53c6dcc0cdf6b0a4fb65c2fa58febb96954f489

Contents?: true

Size: 1.09 KB

Versions: 18

Compression:

Stored size: 1.09 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?('<<'))
			assert(scli.methods.include?('>>'))
			assert(scli.methods.include?('has_read_data?'))
			
		ensure
			ccli.close if (ccli)
			serv.close
		end
	end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
librex-0.0.30 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.29 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.28 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.27 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.26 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.25 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.23 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.21 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.19 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.17 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.13 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.12 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.7 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.6 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.5 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.4 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.3 lib/rex/socket/tcp_server.rb.ut.rb
librex-0.0.1 lib/rex/socket/tcp_server.rb.ut.rb