Ejemplo n.º 1
0
        private int sendAGSByLine()
        {
            try {
                AGS_Package ap = new AGS_Package(ags_data,
                                                 dictionaryfile,
                                                 datastructure);
                String s1 = ap.getContentsAGS();

                TextReader tr = new StringReader(s1);

                String line = "";

                Stream       networkStream = socket.GetStream();
                StreamWriter s_out         = new StreamWriter(networkStream)
                {
                    NewLine = "\r\n", AutoFlush = true
                };

                while ((line = tr.ReadLine()) != null)
                {
                    s_out.Write(line);
                    s_out.WriteLine();
                }

                s_out.Flush();

                // status = enumStatus.AGSSent;
                return(1);
            } catch (Exception e)  {
                Console.WriteLine(e.Message);
                // status = enumStatus.AGSSendFailed;
                return(-1);
            }
        }
Ejemplo n.º 2
0
        private int sendAGSByStream()
        {
            try {
                AGS_Package ap = new AGS_Package(ags_data,
                                                 dictionaryfile,
                                                 datastructure);
                String s1 = ap.getContentsAGS();

                byte[] buffer = new byte[MAX_BUFFER_SIZE];
                int    length = 0;
                int    total  = 0;

                Stream         networkStream = socket.GetStream();
                BufferedStream s_out         = new BufferedStream(networkStream);

                MemoryStream ms = new MemoryStream(Encoding.ASCII.GetBytes(s1));
                // reset to beginning of string'
                ms.Position = 0;

                while ((length = ms.Read(buffer)) != 0)
                {
                    s_out.Write(buffer, 0, length);
                    total = +length;
                }

                s_out.Flush();
                // String msg = "AGS data sent (" + total + ")";
                // System.out.println(msg);
                // status = enumStatus.AGSSent;
                return(1);
            } catch (Exception e) {
                Console.WriteLine(e.Message);
                // status = enumStatus.AGSSendFailed;
                return(-1);
            }
        }