Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try
- {
- $clientList = New-Object System.Collections.ArrayList
- $server = [System.Net.Sockets.TcpListener]12345
- $Server.Start()
- while ($server.Active -eq $True)
- {
- if($server.Pending() -eq $False)
- {
- Update_ClientList($clientList)
- }
- else
- {
- $client = $server.AcceptTcpClient()
- $clientList.Add($client)
- }
- }
- }
- catch
- {
- # Code to handle errors here
- }
- function Update_ClientList
- {
- param ([System.Collections.ArrayList] $ClientList)
- foreach ($client in $ClientList)
- {
- if ($client.Available -gt 0)
- {
- # Data is available on this client
- # Code to read/process the data goes here
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement