/*! 🔌 SocketBox - TCP/UDP Socket networking
*
* ## 📝 概要
* Rustの std::net を基盤とした高性能ネットワーキング Box
* TCP サーバー・クライアント両対応、HTTPサーバー基盤として利用
*
* ## 🛠️ 利用可能メソッド
* ### TCP Server
* - `bind(address, port)` - TCP ソケット bind
* - `listen(backlog)` - 接続待機開始
* - `accept()` - クライアント接続受諾
*
* ### TCP Client
* - `connect(address, port)` - サーバーへ接続
*
* ### IO Operations
* - `read()` - データ読み取り
* - `write(data)` - データ送信
* - `close()` - ソケット閉鎖
*
* ## 💡 使用例
* ```nyash
* // TCP Server
* server = new SocketBox()
* server.bind("0.0.0.0", 8080)
* server.listen(128)
* client = server.accept()
*
* // TCP Client
* client = new SocketBox()
* client.connect("127.0.0.1", 8080)
* client.write("Hello Server!")
* response = client.read()
* ```
*/
use crate::box_trait::{NyashBox, StringBox, BoolBox, BoxCore, BoxBase};
use std::any::Any;
use std::net::{TcpListener, TcpStream};
use std::io::{Write, BufRead, BufReader};
use std::sync::RwLock;
use std::time::Duration;
/// TCP/UDP ソケット操作を提供するBox
#[derive(Debug)]
pub struct SocketBox {
base: BoxBase,
// TCP Server
listener: RwLock