Esempio n. 1
0
        private void OnSendData(object sender, EventArgs e)
        {
            if (!mainSock.IsBound)
            {
                MsgBoxHelper.Warn("서버가 실행되고 있지 않습니다!");
                return;
            }

            string tts = input.Text.Trim();

            if (string.IsNullOrEmpty(tts))
            {
                MsgBoxHelper.Warn("텍스트가 입력되지 않았습니다!");
                input.Focus();
                return;
            }

            byte[] bDts = Encoding.UTF8.GetBytes(tts);

            mainSock.Send(bDts);

            input.Clear();
        }
Esempio n. 2
0
        private void OnFormLoaded(object sender, EventArgs e)
        {
            thisAddress = IPAddress.Parse("210.123.255.192");
            int port = 9000;

            AppendText(chat, string.Format("IP: {0}, Port: {1}", thisAddress, port));

            try
            {
                mainSock.Connect(thisAddress, port);
            } catch (Exception ex)
            {
                MsgBoxHelper.Error("연결에 실패했습니다!\n오류 내용:{0}", MessageBoxButtons.OK, ex.Message);
                Close();
            }

            AppendText(chat, "서버와 연결되었습니다.");

            AsyncObject obj = new AsyncObject(4096);

            obj.WorkingSocket = mainSock;
            mainSock.BeginReceive(obj.Buffer, 0, obj.BufferSize, 0, DataReceived, obj);
        }