forked from VSharp-team/VSharp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
46b9b42
commit 35432c6
Showing
4 changed files
with
87 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
open System | ||
open System.Net | ||
open System.Net.Sockets | ||
open System.Text | ||
|
||
[<EntryPoint>] | ||
let main args = | ||
|
||
// Параметры подключения (можно изменить при необходимости) | ||
let host = "127.0.0.1" // или "localhost" | ||
let port = 35100 | ||
|
||
printfn "Подключение к %s:%i..." host port | ||
|
||
// Создаем TCP-клиент и подключаемся к удалённому хосту | ||
use client = new TcpClient() | ||
client.Connect(host, port) | ||
|
||
// Получаем сетевой поток для записи | ||
use stream = client.GetStream() | ||
printfn "Подключено. Введите строки для отправки (Ctrl+C для выхода)." | ||
|
||
// Бесконечный цикл чтения строк с консоли и отправки их в сокет | ||
let rec sendLoop () = | ||
printf "> " | ||
let line = Console.ReadLine() | ||
match line with | ||
| null | "" -> | ||
// Если ввели пустую строку или EOF (null), | ||
// при желании можно завершить работу или пропустить итерацию. | ||
// В примере завершим отправку. | ||
printfn "Завершение..." | ||
() | ||
| text -> | ||
// Преобразуем строку в байты и отправляем. | ||
// Добавляем перевод строки. | ||
let bytes = Encoding.UTF8.GetBytes(text + Environment.NewLine) | ||
stream.Write(bytes, 0, bytes.Length) | ||
stream.Flush() | ||
// Переходим к следующему циклу | ||
sendLoop() | ||
|
||
sendLoop() | ||
|
||
0 // код возврата из приложения |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters