5

I try to send a code(TLRequestAuthSendCode) but it doesn't come. In what there can be a problem?

Part of code:

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()));
  • 2
    show us some code, and try to create a [SSCCE](http://www.sscce.org) –  Nov 20 '14 at 07:27

3 Answers3

2

can you debug your code and tell if

tcpClient.Connect(connections[0].getAddress(),

Connections[0] has a value?

I'd suggest you change your code to the following:

        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();

I don't see where the code could break, maybe a more detailed description of your problem would be helpful

Luca
  • 1,766
  • 3
  • 27
  • 38
1

TcpClient tcpClient = new TcpClient();

As i tried the code, it mostly seemd to me as if the port was either blocked or already in use. Maybe u have a permission problem there. At least i didnt manage to get a Socket to work with the code like that. Also i didnt dive to deep in your code, but you are using port 443. This is a reserved port with limited access.

sch4um4
  • 11
  • 4
0

You can get started with this, but I have written it in vb.net, not C#.

It will walk you through getting started building your own Telegram-API from scratch.

Also try and get familiar with the online documentation, it's hard but the step by step explanation I gave in that link above on generating your AuthKey, should get you started.

Good Luck

Community
  • 1
  • 1
Charles Okwuagwu
  • 10,538
  • 16
  • 87
  • 157