首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

使用ObjectOutputStream进行socket通信的时候出现固定读到四个字节乱码的问题

问题描述: 最近在写一个通信相关的项目,服务器端和客户端通过socket进行通信。本来想利用read的阻塞特性,服务器端和客户端按照一定的流程进行文件读写。结果发现客户端或者服务器read方法一直都返回乱码。而且读到的一端可能是客户端,可能是服务器端,固定的读到前面有四个字节的乱码,后续读到的字节码都是正常的。 原因分析: 开始以为是流没有正常关闭。修改了代码确保正确关闭之后,发现即使重新启动服务器和客户端,还是会固定读到四个字节乱码。后面查资料分析才找出真正的原因:由于我实现的socket通信既有字符串通

06

【HDU 5007】Post Robot

DT is a big fan of digital products. He writes posts about technological products almost everyday in his blog.  But there is such few comments of his posts that he feels depressed all the day. As his best friend and an excellent programmer, DT asked you to help make his blog look more popular. He is so warm that you have no idea how to refuse. But you are unwilling to read all of his boring posts word by word. So you decided to write a script to comment below his posts automatically.  After observation, you found words “Apple” appear everywhere in his posts. After your counting, you concluded that “Apple”, “iPhone”, “iPod”, “iPad” are the most high-frequency words in his blog. Once one of these words were read by your smart script, it will make a comment “MAI MAI MAI!”, and go on reading the post.  In order to make it more funny, you, as a fan of Sony, also want to make some comments about Sony. So you want to add a new rule to the script: make a comment “SONY DAFA IS GOOD!” when “Sony” appears.

01

MySQL系统变量优化详述

1、全局内存缓冲区 1)key_buffer_size     该变量是只存储MyISAM索引信息的全局内存缓冲区。在对应的.MYI文件中的索引数据从磁盘上被读取出来然后存入这个缓冲区。想要调整key_buffer_size的大小,只需要简单统计所有MyISAM表中总索引的大小,然后随着数据随时间增长而调整。  当这个索引码缓冲区中没有足够的空间来存储新的索引数据时,将会用最近最少使用的的方法覆盖掉旧的页面。 2)innodb_buffer_pool_size     innodb_buffer_pool_size是用来存储所有InnoDB数据和索引的全局内存缓冲区。对完全使用InnoDB的数据库来说,这是个很重要的缓冲区,一定要正确分配,不正确的分配这个缓冲区可能导致额外的磁盘IO开销并降低查询性能。     常见的方法是把innodb_buffer_pool_size设定为RAM的80%,但是很多情况下这样设定不合理,如RAM大小50G,而数据库总量只有2G。     可以使用SHOW GLOBAL STATUS或者SHOW ENGINE INNODB STATUS命令来监控InnoDB缓冲池的使用情况。 MySQL> SHOW GLOBAL STATUS LIKE 'innodb_buffer%'; +---------------------------------------+--------------------------------------------------+ | Variable_name                        | Value                                            | +---------------------------------------+--------------------------------------------------+ | Innodb_buffer_pool_dump_status        | Dumping of buffer pool not started              | | Innodb_buffer_pool_load_status        | Buffer pool(s) load completed at 180330 16:27:30 | | Innodb_buffer_pool_resize_status      |                                                  | | Innodb_buffer_pool_pages_data        | 51679                                            | | Innodb_buffer_pool_bytes_data        | 846708736                                        | | Innodb_buffer_pool_pages_dirty        | 0                                                | | Innodb_buffer_pool_bytes_dirty        | 0                                                | | Innodb_buffer_pool_pages_flushed      | 116888                                          | | Innodb_buffer_pool_pages_free        | 1024                                            | | Innodb_buffer_pool_pages_misc        | 4641                                            | | Innodb_buffer_pool_pages_total        | 57344                                            | | Innodb_buffer_pool_read_ahead_rnd    | 0                                                | | Innodb_buffer_pool_read_ahead        | 0                                                | | Innodb_

01

扫码

添加站长 进交流群

领取专属 10元无门槛券

手把手带您无忧上云

扫码加入开发者社群

相关资讯

热门标签

活动推荐

    运营活动

    活动名称
    广告关闭
    领券