我尝试发送代码(TLRequestAuthSendCode),但是没有。在什么地方可能有问题?
部分代码:
TLContext tlContext = new TLApiContext();
TcpClient tcpClient = new TcpClient();
tcpClient.Connect(connections[0].getAddress(), (int)connections[0].getPort());
TLRequestAuthSendCode tlRequestAuthSendCode = new TLRequestAuthSendCode("PHONE_NUMBER",
0, 19114, "TOKEN", "en");
tlRequestAuthSendCode.serializeBody(new StreamWriter(tcpClient.GetStream()));
您能否调试代码并确定是否
tcpClient.Connect(connections[0].getAddress(),
Connections [0]有值吗?
我建议您将代码更改为以下内容:
public void run() {
connections = new ConnectionInfo[]{
new ConnectionInfo(1, 0, "149.154.167.40", 443)
};
apiState = new ApiState(connections);
doReqCode(connections);
private void doReqCode(connections){
var args = new SocketAsyncEventArgs();
我看不到代码可能在哪里中断,也许对您的问题进行更详细的描述会有所帮助
TcpClient tcpClient = new TcpClient();
当我尝试代码时,在我看来,端口似乎已被阻塞或已经被使用。也许您那里有权限问题。至少我没有设法让一个Socket像这样的代码一起工作。另外,我没有深入探讨您的代码,但是您使用的是端口443。这是保留访问权限的保留端口。